This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Gcc 3.0, printf() and exim-3.30


On Tue, 19 Jun 2001, Vadim Vygonets stipulated:
> A macro?  True?

Looks legal to me...

>> gcc -c -DNOPOSIX -O  pcretest.c
>> pcretest.c:474:1: directives may not be used inside a macro argument

Correct, but not relevant to this situation, I think.

> 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 :)

I think your #if itself is triggering a bug in GCC; a workaround may be
to say

#if !defined(NOPOSIX)

instead.

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.

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.

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?

(You know infinitely more about this than do I; I am a neophyte in these
waters.)

> #undef printf

This will, of course, do nothing; GCC does not define a printf macro,
and I hope that exim doesn't :) Defining printf is definitely the job of
the libc :)

> If that doesn't work, well, I suppose the thing can be rewritten so as
> to duplicate the text in the source. What an annoying restriction.

No need; two parentheses will solve your problem, (I think, maybe,
perhaps).


If that doesn't work, producing a stripped-down testcase and reporting
the potential bug with `gccbug' would be much appreciated.

-- 
`This will immediately become a flamewar.' --- Mark Mitchell


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]