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: Nix <nix at esperi dot demon dot co dot uk>
- Subject: Re: Gcc 3.0, printf() and exim-3.30
- From: Neil Booth <neil at daikokuya dot demon dot co dot uk>
- Date: Thu, 21 Jun 2001 07:23:41 +0100
- Cc: Vadim Vygonets <vadik at vygo dot net>, gcc at gcc dot gnu dot org
Nix wrote:-
> >> pcretest.c:474:1: directives may not be used inside a macro argument
>
> Correct, but not relevant to this situation, I think.
No, it is - trust the messages!
> > The code in question reads:
> >
> > printf(" -d debug: show compiled code; implies -i\n"
> > " -i show information about compiled pattern\n"
> > #if !defined NOPOSIX
> > " -p use POSIX interface\n"
> > #endif
> > " -s output store information\n"
> > " -t time compilation and execution\n");
> >
> > It looks as if gcc 3.0 has printf defined as a macro. IMHO this is
> > lunacy.
>
> Nope; printf is not a macro, and GCC does not define printf :)
No, it is - trust the diagnostics! (I agree about the lunacy, but it's
in glibc).
> I think your #if itself is triggering a bug in GCC; a workaround may be
> to say
>
> #if !defined(NOPOSIX)
>
> instead.
No.
> The error you're getting is meant to be triggered by code like
>
> #if #else
>
> which is obvious nonsense; but it doesn't seem to me that this should be
> triggered here.
No - I don't see a macro nor an argument here, so how can this be what
the message is about?
In fact, your line
#if #else
is a valid GNU C line, though it may not mean what you think it does.
It is a #if that tests for whether or not an assertion called "else"
has been asserted.
> It looks to me like gcc/cppexp.c:parse_defined() and/or the tokenizer is
> fubared, and it doesn't realize that the #if has finished, and
> interprets the #endif as part of the #if expression.
No.
> Zack/Neil, is my guess correct, or is this something to do with string
> literal concatenation and macro expansion getting tangled up or
> something (I seem to recall that causing problems in the past), or is
> that code actually invalid, or is this something completely different?
No - it's just what the error message says. Glibc defines printf as a
macro when you compile with optimisation on. So you cannot have
directives inside a printf call. I don't know if / why this works
with GCC 2.95.2.
The error message should probably be changed to
pcretest.c:474:1: directives may not be used inside the macro "printf"
so that users are more inclined to believe the message the compiler
gives them :-)
Neil.