0

I have a pre-processor directive as such,

//#define SPEC_CONTROL  // Is not defined, but can be if need be
#define SPEC_A_CONTROL  // Is defined

#ifdef SPEC_CONTROL || SPEC_A_CONTROL
    ; // do something
#else
    ; // do something else
#endif

Is it correct syntax to use the || in the manner I did?

4

2 回答 2

1

I can assure yout that at least

#if defined(SPEC_CONTROL) || defined(SPEC_A_CONTROL)

works on Windows and several UNIX platforms. Im not sure about

#ifdef SPEC_CONTROL || SPEC_A_CONTROL
于 2013-07-02T13:30:16.687 回答
1

You can use boolean logic in a C preprocessor directive by using the if defined directive.

See this post for more information: C Preprocessor testing definedness of multiple macros

于 2013-07-02T13:31:10.597 回答