My c code uses 'memset' and 'close'. And I have added:
#include <stdio.h> #include <glib.h> #include <stdlib.h>
But I still get these warnings:
main.c:259: warning: implicit declaration of function ‘memset’ main.c:259: warning: incompatible implicit declaration of built-in function ‘memset’ main.c:268: warning: implicit declaration of function ‘close’ main.c:259: warning: incompatible implicit declaration of built-in function ‘close’
Can you please tell me how can I resolve these warnings?
Thank you.
Function name typo: Often the function name of the declaration does not exactly match the function name that is being called. For example, startBenchmark() is declared while StartBenchmark() is being called. I recommend to fix this by copy-&-pasting the function name from the declaration to wherever you call it.
Implicit declaration of functions is not allowed; every function must be explicitly declared before it can be called. In C90, if a function is called without an explicit prototype, the compiler provides an implicit declaration.
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.
You need:
#include <string.h> /* memset */ #include <unistd.h> /* close */
in your code.
References: POSIX for close
, the C standard for memset
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With