#ifdef question

M

Mark

Hello,

I see constructions like:

#ifdef FOO || defined BAR
....
#endif

and compiler's complaints "warning: extra tokens at end of #ifdef
directive", obviously it should be:

#if defined FOO || defined BAR
....
#endif

Does the standard explicitly say so? Could you point at the relevant part?
Thanks.

Mark
 
N

Noob

Mark said:
Hello,

I see constructions like:

#ifdef FOO || defined BAR
...
#endif

and compiler's complaints "warning: extra tokens at end of #ifdef
directive", obviously it should be:

#if defined FOO || defined BAR
...
#endif

Does the standard explicitly say so? Could you point at the relevant part?
Thanks.

(With respect to C89)

3.8 PREPROCESSING DIRECTIVES

if-group:
# if constant-expression new-line group<opt>
# ifdef identifier new-line group<opt>
# ifndef identifier new-line group<opt>

identifier:
nondigit
identifier nondigit
identifier digit

nondigit: one of
_ a b c d e f g h i j k l m
n o p q r s t u v w x y z
A B C D E F G H I J K L M
N O P Q R S T U V W X Y Z

digit: one of
0 1 2 3 4 5 6 7 8 9

A line
#ifdef FOO || defined BAR
is not accepted by the grammar

After the identifier, there can only be a new-line.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top