Determining when DEBUG is in effect

Does anyone know how to test that the "DEBUG" compiler option (active when "Debug Information" is checked on the Target Options Output tab) is enabled? I would like a simple test such as

#ifdef DEBUG
but this does not work of course.

Thanks.

Parents
  • Could you turn the problem around?

    Instead of enabling the compiler debug info in the uVision options, you define (or not) a preprocessor symbol, and then use that in your source files to determine whether or not to enable debug features; eg,

    #ifdef DEBUG_MODE
    #pragma db
    //Debug mode - TRACE causes printf output
    #include <stdio.h>
    #define TRACE(params) printf params;
    #else
    //Release mode - TRACE expands to nothing!
    #define TRACE(params)
    #endif

    See this thread for a discussion of TRACE-type macros:
    http://www.keil.com/forum/docs/thread3796.asp

Reply
  • Could you turn the problem around?

    Instead of enabling the compiler debug info in the uVision options, you define (or not) a preprocessor symbol, and then use that in your source files to determine whether or not to enable debug features; eg,

    #ifdef DEBUG_MODE
    #pragma db
    //Debug mode - TRACE causes printf output
    #include <stdio.h>
    #define TRACE(params) printf params;
    #else
    //Release mode - TRACE expands to nothing!
    #define TRACE(params)
    #endif

    See this thread for a discussion of TRACE-type macros:
    http://www.keil.com/forum/docs/thread3796.asp

Children
More questions in this forum