Reputation: 23
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
Upvotes: 2
Views: 2523
Reputation: 75130
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.
Upvotes: 5
Reputation: 163228
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.
Upvotes: 5