This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCSTUDIO: Writing a debugmode using #ifdef

Part Number: CCSTUDIO
Other Parts Discussed in Thread: PGA970

Hello,
Im using a PGA970 microcontroller and am programming it with C in CCS 10. My code is working so far but i decided to implement a debugmode . The theory seems very simple , if you write 1 to Debugmode when its defined it should compile "doSomething" if there is a 0 it shouldnt. But both configurations compile "doSomething" and run the code. Did I misunderstand something there or is my setup not capable of using #ifdef?

#define Debugmode      0      // For Debugging turn Debugmode ON
//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
void main(void)
 {
    init();
    while(1)
    {
        #ifdef Debugmode
        doSomething();
        #endif
    }
 }

Regards,
Paul

  • Hi Paul,

    Even though you are defining Debugmode as 0, the preprocessor is still defining it as something, so the code in the ifdef statement will compile. You would need to remove the definition statement completely or comment it out for the compiler to skip the doSomething() function.

    Regards,

    Scott