example:
gcc -O3 -funroll-loops -Iinclude -c src/xlib/conlib.c -o obj/xlib/conlib.o
src/xlib/conlib.c: In function 'ClearConsole':
src/xlib/conlib.c:103: warning: incompatible implicit declaration of
built-in fu
nction 'memset'
src/xlib/conlib.c: In function 'CursorMoveRight':
src/xlib/conlib.c:122: warning: incompatible implicit declaration of
built-in fu
nction 'memcpy'
src/xlib/conlib.c:124: warning: incompatible implicit declaration of
built-in fu
nction 'memset'
src/xlib/conlib.c: In function 'PutChar':
src/xlib/conlib.c:155: warning: incompatible implicit declaration of
built-in fu
nction 'memcpy'
src/xlib/conlib.c:158: warning: incompatible implicit declaration of
built-in fu
nction 'memset'
src/xlib/conlib.c: In function 'NewConsole':
src/xlib/conlib.c:173: warning: incompatible implicit declaration of
built-in fu
nction 'memset'
What could be the reason?
bye
--
Florian Xaver <http://www.flox.at.tf>
Dr-DOS Wiki <http://www.drdos.org>
SWORD - a nice GUI library for DOS/DJGPP
<http://www.flox.at.tf>
> What could be the reason?
Failure to explicitly declare memset() before using it. I.e. failure
to #include <string.h>. Bad style, and potentially harmful.
--
Hans-Bernhard Broeker (bro...@physik.rwth-aachen.de)
Even if all the snow were burnt, ashes would remain.
In <string.h>
#include <string.h>
you will find a declaration
void *memset(void *buffer, int ch, size_t num);
Note that memset returns a pointer to void. But your code does not have
a declaration of memset before use (am I a mindreader, or what?). That
means that it has an implicit declaration (before the current standard)
with a return type of int. [In the current standard, use without
declaration is an error.]
Obviously, an int is not a pointer-to-void.
Fix this by #includeding <string.h>
Similar comments apply to your other errors.
[..]
Beginning with some recent version of gcc, my programs (even
"hello.c") would not compile without many such warnings about
some function or other. I searched the gcc docs and added
'-fno-builtin' to the gcc invocation to suppress the use of
builtin prototypes.
--
j
That doesn't remove the prototypes, that removes the *builtins* too.
Thus, gcc will always call the library function, even if it could have
replaced the call with a few opcodes.
It's far better to include the right headers and get the best
performance gcc can provide.