cc-preprocessor

How do I generate an error or warning in the C preprocessor?


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?


Solution

  • Place anywhere:

    #ifndef DEBUG
    #error "Only Debug builds are supported"
    #endif
    

    For reference: Diagnostics