Michael Tautschnig <[email protected]> writes:

>> In this specific case, it would probably be fine for the MIT Kerberos code
>> base to change this line to instead be:
>> 
>>     #if !defined(TARGET_OS_MAC)
>           ^ (Sure? I don't think negation is due here.)

Ack, you're correct.  I reversed the sense.

> So I do believe that

> ^\s*#\s*if\s+[a-zA-Z_][a-zA-Z0-9_]*\s*$

> is almost always wrong as those should really be #ifdef ... or #if
> defined(...), but there may be more complex expressions that are wrong
> as well. Fixing this appears to be a worthwhile (but indeed possibly
> non-trivial) goal.

There used to be a coding style that recommended #if over #ifdef for stuff
like this, but I forget why.

I'm not sure if you can use #ifdef with #elif.  I've always avoided doing
so, but have to admit having not looked it up in the C standard.

I generally agree with you that it would be better to write -Wundef-clean
code, but a lot of examples from, say, Autoconf are not -Wundef-clean, so
I suspect there's a lot of this out there.  And since behavior of an
undefined variable in preprocessor directives is well-defined by the
standard, you'll probably get pushback against making it a rule.

-- 
Russ Allbery ([email protected])               <http://www.eyrie.org/~eagle/>


-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to