How do I implement no-op macro in C++?
#include
#ifdef NOOP
#define conditional_noop(x) what goes here?
#else
#
As mentioned before - nothing.
Also, there is a misprint in your code.
it should be #else not #elif. if it is #elif it is to be followed by the new condition
#include <iostream>
#ifdef NOOP
#define conditional_noop(x) do {} while(0)
#else
#define conditional_noop(x) std::cout << (x)
#endif
Have fun coding! EDIT: added the [do] construct for robustness as suggested in another answer.
#ifdef NOOP
#define conditional_noop(x)
#elif
nothing!
As this is a macro, you should also consider a case like
if (other_cond)
conditional_noop(123);
to be on the safe side, you can give an empty statement like
#define conditional_noop(X) {}
for older C sometimes you need to define the empty statment this way (should also get optimized away):
#define conditional_noop(X) do {} while(0)