I have a program that must be compiled only in DEBUG mode. (testing purpose)
How can I have the preprocessor prevent compilation in RELEASE mode?
I have a program that must be compiled only in DEBUG mode. (testing purpose)
How can I have the preprocessor prevent compilation in RELEASE mode?
C provide a #error statement, and most compilers add a #warning statement. The gcc documentation recommends to quote the message.
You can use a error directive for that. The following code will throw an error at compile time if DEBUG is not defined:
#ifndef DEBUG
#error This is an error message
#endif
If you simply want to report an error:
#ifdef RELEASE
#error Release mode not allowed
#endif
will work with most compilers.