This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

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.

  • "how to test that the 'DEBUG' compiler option ... is enabled?."

    See my "digression" (Posted 10/31/02 8:01:43) in this thread:
    http://www.keil.com/forum/docs/thread1940.asp
    - This is another one to add to the list!

  • 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

  • This is exactly what I meant and need. I have numerous #ifdef's in the code allowing it to be built for multiple flavors of the same machine. Based on an ID being defined, I place an identifying letter on the end of a part number string to show all the options it was compiled with while it is in development. This allows a double check to make sure a piece of code being tested is designed for the machine in question.

    When "Debug Information" is selected, is there anything that I can do an #ifdef on to determine that the debug code is compiled in (source file names, line numbers, etc)?

  • I have found so many things I need done that uVision can not do (file replacement/renaming - debug mode - many builds from same group of files) so I have reverted to commandline operation. I do this by regular .bat files and if if you want to know how, let me know.

    Erik