(printf) ("hello world\n");

Joseph S. Myers jsm@polyomino.org.uk
Wed Dec 10 14:08:00 GMT 2003


On Wed, 10 Dec 2003, Segher Boessenkool wrote:

> On 10-dec-03, at 13:27, Robert Dewar wrote:
> > Is it really true that the name printf is reserved? Is a C program not
> > allowed to define its own printf function (which might or might not be
> > varargs)? What's the story here?
> 
> It is reserved only in translation units that have stdio.h #include'd.

It is reserved (in a hosted environment) as an identifier with external
linkage regardless of what headers are included (7.1.3#1).  If <stdio.h>
is included then it is alse reserved as a macro name (which however you
may #undef) and as an identifier with file scope.

(C94 reserved certain identifiers with external linkage iff the
corresponding header was included in _any translation unit in the
program_.  This was not carried forward into C99; the functions added in
C94 are now unconditionally reserved as identifiers with external linkage
regardless of the headers included.)

-- 
Joseph S. Myers
jsm@polyomino.org.uk



More information about the Gcc mailing list