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?
#error is a preprocessor directive in C which is used to raise an error during compilation and terminate the process. Syntax: #error <error message> C. Usually, the error message is associated with preprocessor conditional statements like #if, #ifdef and others.
A preprocessor error directive causes the preprocessor to generate an error message and causes the compilation to fail. The #error directive is often used in the #else portion of a #if – #elif – #else construct, as a safety check during compilation.
Description. In the C Programming Language, the #warning directive is similar to an #error directive, but does not result in the cancellation of preprocessing. Information following the #warning directive is output as a message prior to preprocessing continuing.
The double-number-sign or token-pasting operator (##), which is sometimes called the merging or combining operator, is used in both object-like and function-like macros. It permits separate tokens to be joined into a single token, and therefore, can't be the first or last token in the macro definition.
Place anywhere:
#ifndef DEBUG #error Only Debug builds are supported #endif
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