Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

incompatible implicit declaration of built-in function...

1,285 views
Skip to first unread message

Florian Xaver

unread,
May 9, 2006, 9:10:04 AM5/9/06
to
Hi!

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>


Hans-Bernhard Broeker

unread,
May 9, 2006, 9:31:09 AM5/9/06
to
Florian Xaver <wosredii...@aon.at> wrote:
> src/xlib/conlib.c:103: warning: incompatible implicit declaration of
> built-in function 'memset'
[...]

> 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.

Martin Ambuhl

unread,
May 9, 2006, 12:16:46 PM5/9/06
to
Florian Xaver wrote:
> Hi!
>
> 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'

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.
[..]

JT Williams

unread,
May 9, 2006, 1:30:21 PM5/9/06
to dj...@delorie.com
> warning: incompatible implicit declaration of built-in function 'memset'

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

DJ Delorie

unread,
May 9, 2006, 2:22:06 PM5/9/06
to dj...@delorie.com

> I searched the gcc docs and added '-fno-builtin' to the gcc
> invocation to suppress the use of builtin prototypes.

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.

0 new messages