Is there a preprocessor directive that checks whether a constant is not defined. I am aware of the #ifndef
directive but I am also looking for a #elif not defined
directive. Does #elif not defined
exist?
This is how I would use it:
#define REGISTER_CUSTOM_CALLBACK_FUNCTION(callbackFunctName) \
#ifndef CUSTOM_CALLBACK_1 \
#define CUSTOM_CALLBACK_1 \
FORWARD_DECLARE_CALLBACK_FUNCTION(callbackFunctName) \
#elif not defined CUSTOM_CALLBACK_2 \
#define CUSTOM_CALLBACK_2 \
FORWARD_DECLARE_CALLBACK_FUNCTION(callbackFunctName) \
#elif not not defined CUSTOM_CALLBACK_3 \
#define CUSTOM_CALLBACK_3 \
FORWARD_DECLARE_CALLBACK_FUNCTION(callbackFunctName) \
#endif
How about the
#elif !defined(...)
But you've got bigger problems - the trailing \
exclude the other directives - or rather make them illegal. So, even with the valid syntax, your definitions won't do what you want.
You'll need to move the initial define inside the conditions.
#ifndef CUSTOM_CALLBACK_1
#define CUSTOM_CALLBACK_1
#define REGISTER_CUSTOM_CALLBACK_FUNCTION(callbackFunctName) \
FORWARD_DECLARE_CALLBACK_FUNCTION(callbackFunctName)
#elif !defined(CUSTOM_CALLBACK_2)
//.....