I have a bunch of code that relies on a preprocessor constant.
I'd like to have a macro that conceptually works like this:
#define A_OR_B(a,b) \
#ifdef A \
(a) \
#else \
(b) \
#endif
And I'd use it like abc(A_OR_B(1, 2));
Right now I'm doing:
#ifdef A
abc(1)
#else
abc(2)
#endif
And I don't like that. Any suggestions? I'm using objective C. I thought I might be able to do something with a C++ template but objective C isn't a superset of C++, only C.
I could have a function that that does the check but I'd rather not have the function call overhead... but right now I think that is a better idea than all my #ifdefs...
I'd like to have a macro that conceptually works like this:
#define A_OR_B(a,b) \
#ifdef A \
(a) \
#else \
(b) \
#endif
And I'd use it like abc(A_OR_B(1, 2));
Right now I'm doing:
#ifdef A
abc(1)
#else
abc(2)
#endif
And I don't like that. Any suggestions? I'm using objective C. I thought I might be able to do something with a C++ template but objective C isn't a superset of C++, only C.
I could have a function that that does the check but I'd rather not have the function call overhead... but right now I think that is a better idea than all my #ifdefs...

