This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: (printf) ("hello world\n");
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