简体   繁体   中英

Multiple #define within #ifdef or #ifndef

This is a simple question, but I have not ran across similar code before to know the answer. Basically, am I allowed to have more than two #define in an #ifdef or #ifndef statement? For a basic example:

    #ifdef __GNUC__
        #define HELLO(x) x
        #define WORLD(y) y
    #else
        #define __attribute__(x)
        #define expect(expression, value) (expression)
    #endif

Thank you

Of course you are. This is perfectly valid.

You can have as many C statements or preprocessor directives within a preprocessor block as you want.

Yes, you may have as many preprocessor directives or just normal C++ statements between an #ifdef / #ifndef ... [ #else ]... #endif block as you want.

This is a simple enough question that you probably should have tried it before asking though.

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