今天寫一個程式的時候出現了如下錯誤:
written_amount.c: In function ‘do_one_group’:
written_amount.c:33:3: warning: incompatible implicit declaration of built-in function ‘strcat’
written_amount.c:41:3: warning: incompatible implicit declaration of built-in function ‘strcat’
written_amount.c:45:3: warning: incompatible implicit declaration of built-in function ‘strcat’
written_amount.c: In function ‘written_amount’:
written_amount.c:55:3: warning: incompatible implicit declaration of built-in function ‘strcpy’
自己由于大意沒發現原因,搜了下原來是缺少了頭檔案。先把搜的結果如下:
In C, using a previously undeclared function constitutes an implicit declaration of the function. In an implicit declaration, the return type is
int
if I recall correctly. Now, GCC has built-in definitions for some standard functions. If an implicit declaration does not match the built-in definition, you get this warning.
To fix the problem, you have to declare the functions before using them; normally you do this by including the appropriate header. I recommend not to use the -fno-builtin-* flags if possible.