简体   繁体   中英

What does #ifdef 1 in C++

in C++, I know that programmers use #ifdef 0 to block out code from running, but in this same project I see a lot of #ifdef 1 . Does this mean that the code always runs? Unfortunately the code does not compile so I can't just run and test!

#ifdef 1 is ill-formed. The #ifdef directive requires a single identifier; 1 is not an identifier.

#ifdef x is equivalent to #if defined(x) . The defined preprocessing operator yields true if the identifier names a defined macro (ie, a macro that has been defined with #define and not yet undefined via #undef ) and false otherwise.

The #if directive enables or disables compilation of the lines between it and the corresponding #else , #elif , or #endif directive that follows it (the directives nest).

Chances are, what you are really looking for is #if 1 (or #if 0 ), which is valid.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM