what's the "#define XXX" 's value?
it has no value but it seems no compile error .normally the define is define type replace, but it is define type wiouht replace str.
It'll replace the replacement text by nothing:
#define FOO
int FOO main() FOO
{
}
Moreover, #ifdef FOO
will succeed.
Empty defines can be quite useful, for example in this (naive) functional form:
#ifndef NDEBUG
# include <cstdlib>
# define MakeSureThat(X) if (!(X)) { std::abort(); }
#else
# define MakeSureThat(X)
#endif
Usage:
void do_stuff(Foo * p)
{
MakeSureThat(p != nullptr); // won't generate any code if NDEBUG
}
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