This question already has an answer here:
- Conditional macro text replacement 4 answers
Please note c++03! any c++11 solutions are not good for me, but do post them just for knoledge sake
I know the preprocessor can do things like
#define FOO 4
#if FOO == 4
cout<<"hi"<<endl;
#endif
What I need is
#define BAR(X)\
#if X == 4\
cout<<"hi"<<endl;\
#endif
main.cpp
BAR(4)
I don't see why all the needed information wouldn't be available in preprocessor time.
Please tell me how to do this correctly, or why this isn't possible and how to bypass it.
edit 1: A normal if condition won't work for my case, because I also do things like
#define BAR(X)\
#if X == 4\
int poop;
#elif
double poop;
#endif
Thanks
Aucun commentaire:
Enregistrer un commentaire