Is it possible to do something like this:
#define F(x) \
#ifdef DOUBLE \
2*x \
#else \
x \
#endif
so that when I use F
, what it expands to depends on whether the macro DOUBLE
is defined? I don't think so, but I'm hopeful. GNU expansions are fine.
Edit In response to some of the answers, I'm really using this to do some code generation, where the code is slightly different depending on where it gets defined. Because of the order in which some files are included and where the relevant macros need to be defined, switching it around that way requires a bit of factoring. I may have to do it, but would be thrilled if I don't have to unpaint myself from this corner!
What's wrong with
#ifdef DOUBLE
#define F(x) (2 * (x))
#else
#define F(x) (x)
#endif
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With