코드 c를 크로스 컴파일 :경고
#include <string.h>
//Return copy of str string from index position and len length
char *StrCpy2(char *str, unsigned short index, unsigned char len)
{
char *text;
text = (char *)malloc(sizeof(char)*(len+1));
if (text == NULL) return text;
strncpy(text, str + index, len);
text[len] = '\0';
return text;
}
이 파일 라인 존중
콘솔 출력 :
Compiling file: String.c
arm-none-eabi-gcc -c -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -ffast-math -O0 -ffunction-sections -fdata-sections -Wall -Wstrict-prototypes -Wextra -std=gnu99 -g -ggdb3 -fverbose-asm -Wa,-ahlms=out/String.lst -DSTM32F40_41xxx -DUSE_STM324x7I_EVAL -MD -MP -MF out/String.d -I. -IBACnet/inc -IBACnet/inc/objects -Iinc -Ilib/drivers/inc -Ilib/eval -IUI/inc -IuIP/inc String.c -o out/String.o
String.c: In function 'StrCpy2':
String.c:39:2: warning: implicit declaration of function 'strncpy' [-Wimplicit-function-declaration]
strncpy(text, str + index, len);
^
String.c:39:2: warning: incompatible implicit declaration of built-in function 'strncpy'
String.c:39:2: note: include '<string.h>' or provide a declaration of 'strncpy'
뭔가가 stm32f1에서 포팅 중에 잘못 때문에 내가 잃어버린 느낌을 stm32f4 및 codesourcery 툴 체인을 최첨단 툴 체인 (this one)으로 옮깁니다. 보시다시피 이미 포함되어 있습니다. 어쩌면 일부 #define이 올바르지 않을 수 있습니다. 어쩌면 이클립스 또는 시스템의 일부 경로가 잘못되었을 수 있습니까?
'strncpy'가 다른 툴체인의'string.h'에 정의되어 있지 않은 것처럼 들립니다. 'string.h' 파일을 검사하면 쉽게 확인할 수 있습니다. –
IDE 경로 아래에' "string.h"'라는 이름의 모든 파일을 찾으십시오 (일반적으로' "include"'라는 폴더에 있음). 이 파일들 각각에서 'strncpy'를 검색하십시오. stm32f1 프로젝트에 포함 된 것과 같은 소리가이 함수를 선언하지만 stm32f4 프로젝트에 포함시키는 것은 아닙니다. 마지막으로, stm32f4 프로젝트 설정에서'include' 경로를 stm32f1 프로젝트 설정의 경로와 동일하게 변경하십시오. –
'string.h'에'strncpy' 선언이 있습니까? 그곳에 있어야하지만 어쩌면 구형 툴체인이나 뭔가를 사용하고있을 수도 있습니다. 어쨌든,이 기능을 직접 작성할 수 있습니다. 그렇게하기가 어렵지 않습니다. – ForceBru