我对strncpy_s的理解是,它是 C11 标准的一部分,且包含在string.h头文件中。不清楚为什么编译器不将strncpy_s识别为已存在的标准函数。
我的编译器是 GNU11,按照我的理解,它理应支持 C11 标准(因此也应包含strncpy_s函数)。浸膏和错误如下
../Core/Src/messageprocesser.c: In function 'send_Message':
../Core/Src/messageprocesser.c:56:2: warning: implicit declaration of function 'strncpy_s'; did you mean 'strncpy'? [-Wimplicit-function-declaration]
56 | strncpy_s((char*) outputMessage + COMMAND_CHAR, COMMAND_LENGTH, (const char*) cmd, COMMAND_LENGTH);
| ^~~~~~~~~
| strncpy
c:\st\stm32cubeide_1.6.0\stm32cubeide\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.9-2020-q2-update.win32_1.5.0.202011040924\tools\arm-none-eabi\bin\ld.exe: Core/Src/messageprocesser.o: in function `send_Message':
C:/Users/User/STM32CubeIDE/workspace_1.6.0/usbtest/Debug/../Core/Src/messageprocesser.c:56: undefined reference to `strncpy_s'
|
|