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: thoughts on martin's proposed patch for GCC and UTF-8


>>   #if defined (FOO) && (FOO == 1)
>> 
>> and:
>> 
>>   #ifdef FOO
>>   #if FOO == 1
>> 
>Good points.  The second isn't a problem, though, since if FOO isn't
>defined, we're skipping when we see #if, and don't need too parse the
>expression.  In fact, if I remember correctly, ANSI forbids parsing of
>the expression (other than recognizing pp-tokens).

That's good to hear, and I had hoped it would be the case, but thought
I should mention it anyway.

>The first case is more important, and one I hadn't thought of.
>However, the boolean operators that short circuit are the only ones
>that don't use one operand, so it seems consistent with C to not
>evaluate (and hence not warn about) arguments that are short
>circuited.  I believe this isn't ad hoc, and avoids all spurious
>warnings in a consistent manner.

It sounds like you're saying the only binary operators are && and
||, which doesn't sound quite right.  && and || are the logical AND
and OR operators, according to my 1998-12-07 draft copy of the ANSI
C standard, and I believe the &, |, and other bitwise operators,
plus the +, -, * and / integer operators are supported for preprocessor
directives as well.

But I'm not sure this changes what you're saying.

What might, though, is the implementation.  It might insist on
expanding macros beyond a short-circuit, and, if it does, you
can't just change it so that, when it replaces an undefined
macro with 0, it optionally warns.

        tq vm, (burley)


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