Undefined functions in C

Ian Wienand ianw@gelato.unsw.edu.au
Sun Feb 6 18:15:00 GMT 2005


Hi,

Googling around, you will find many people saying that C99 disallows
undefined functions (e.g [1]), often citing C99 6.5.2.2.  My reading
of this doesn't seem to suggest it disallows undefined functions; in
fact it talks about type promotion rules for undefined functions.

And indeed, even with -std=c99 gcc still only warns about undefined
functions (and assumes they return int, etc), not gives an error.
This is particularly annoying on 64 bit architectures where the top
bits of pointers get stripped when converted to int when people forget
to include the right headers.  A compiler error (yes it warns, but
people often ignore it) rather than a segfault would be more useful.

Can anyone point me to where C99 explicitly disallows a function
without a declaration, and if so why doesn't gcc in C99 mode give an
error rather than falling back to the C89 semantics?  Or are the
numerous people suggesting C99 disallows undefined functions
incorrect?

-i
ianw@gelato.unsw.edu.au
http://www.gelato.unsw.edu.au

[1] http://david.tribble.com/text/cdiffs.htm ("Implicit function declarations")
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <https://gcc.gnu.org/pipermail/gcc-help/attachments/20050206/2fb3d741/attachment.sig>


More information about the Gcc-help mailing list