lundi 20 juillet 2020

Compiler warning/error when using #if on something that is undefined

Consider the following example:

#define FOO false
#if FOO
void foo(){}
#endif

Obviously, foo() does not exist. But when I forget to define FOO, the result is the same:

#if FOO
void foo(){}
#endif

Is there any way to have foo() {} conditionally, depending on FOO, but yielding a warning or error when FOO has not been defined at all?

Aucun commentaire:

Enregistrer un commentaire