This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Gcc 3.0, printf() and exim-3.30
- To: "Zack Weinberg" <zackw at stanford dot edu>
- Subject: Re: Gcc 3.0, printf() and exim-3.30
- From: Nix <nix at esperi dot demon dot co dot uk>
- Date: 21 Jun 2001 22:43:26 +0100
- Cc: Vadim Vygonets <vadik at vygo dot net>, gcc at gcc dot gnu dot org
- References: <20010620232816.G12387@stanford.edu>
On Wed, 20 Jun 2001, Zack Weinberg spake:
> On Wed, Jun 20, 2001 at 11:45:18PM +0100, Nix wrote:
>> Nope; printf is not a macro, and GCC does not define printf :)
>
> But GNU libc does, when used with GCC in optimizing mode. The C
> standard permits the library to define any standard function as a
> macro, provided that there is a real function as well.
I checked for this case, and couldn't find any sign of a printf() macro.
(I plead hay-fever induced semi-blindness and simple stupidity, m'lud.)
> The C standard also says
>
> If there are sequences of preprocessing tokens within the list
> of arguments that would otherwise act as preprocessing
> directives, the behavior is undefined.
>
> (C99 6.10.3 paragraph 11). This is just the case you have tripped
> over. The error message means exactly what it says - you cannot use
> any directive in text which is read as the arguments of a macro.
I noticed that, but I couldn't convince GCC to give me a printf() macro,
and I missed the definition in bits/stdio.h somehow.
Of course the failure to replicate is because my try-by-default
optimization flag is -Os :(
> You can #undef printf immediately after #include <stdio.h>, or write
>
> (printf)(" -d ..."
> ...
> );
>
> which will suppress macro expansion for that use only.
(Random aside: This is less portable than #undef, of course, but since
the macro is only defined if __GNUC__, this is not a problem.)
> There doesn't
> seem to be a way to prevent glibc from defining all its stupid macros.
We need a feature macro _LEAVE_OPTIMIZATION_TO_THE_COMPILER...
>> I think your #if itself is triggering a bug in GCC; a workaround may be
>> to say
>>
>> #if !defined(NOPOSIX)
>
> I don't think that has anything to do with it.
Neither do I, now.
>> #if #else
>>
>> which is obvious nonsense; but it doesn't seem to me that this should be
>> triggered here.
>
> #if #else is actually acceptable to GCC, it counts as a use of the
> deprecated "assertions" extension.
Whenever I manage to erase assertions from my mind, they come back and
bite me. I tried to forget about digraphs recently too, only to find
them attacking in turn...
--
`This will immediately become a flamewar.' --- Mark Mitchell