#ifdef doesn't work?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable
        I have a debug configuration, with DEBUG defined as a preprocessor definition. I'm trying to use it so that in debug it will use printf, but won't use it in release. However, in debug, it isn't recognizing the symbol as being defined, so it doesn't include the code (see attached screen shot). Thanks, David   
0 Likes
1 Solution
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

In project -> build settings set at Compiler -> general the Preprocessor definitions to "DEBUG", only for the assembler this feature is set.

   

 

   

Bob

View solution in original post

0 Likes
7 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Your definition is external to the compiler and online-checker, so there is no hint in the code that it is defined.

   

Afaik is the symbol "DEBUG" already defined when you use "Debug" build settings, for "Release", "NODEBUG" is defined.

   

 

   

Bob

0 Likes
Anonymous
Not applicable
        DEBUG (in the debug configuration) and NDEBUG (in the release configuration) were defined already in the configurations in the preprocessor...So the compiler should see that it is defined...that is the whole point of having a preprocessor directive.   
0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Yes, the COMPILER should see that. But the compiler is not called/started yet. And the definitions are made on the command-line.

   

 

   

Bob

0 Likes
Anonymous
Not applicable
        After doing a build in debug, the code is not included / built. It is omitted.   
0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Can you post a complete project showing that error, so that we all can have a look at all of your settings? To do so, use
Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file.



Bob
 

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable
        I added a simple statement in main.c, line 65.   
0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

In project -> build settings set at Compiler -> general the Preprocessor definitions to "DEBUG", only for the assembler this feature is set.

   

 

   

Bob

0 Likes