User forums > Using Code::Blocks

Editor defines enlightenments (Debug | Release)

(1/2) > >>

dams:
Is there a preprocessor variable defined in Code::Blocks for Debug / Release target ? On some IDE there's the DEBUG variable, some people says NDEBUG is define on release.
So I use a classic #ifdef DEBUG preprocessor lines, passing it to the make command with the -DDEBUG CXXFLAGS, that works but I would like to enlighten its block when I switch to the Debug build target...
How can I enlight the Debug preprocessor sections when I switch to the Debug target ?

BlueHazzard:
Are you talking about passing the right parameter to the compiler, or are you talking about code highlighting?


--- Quote ---Is there a preprocessor variable defined in Code::Blocks for Debug / Release target ?
--- End quote ---
No, codeblocks does nothing you don't tell him (?it?). As far as i know it adds the "-g" flag automatically, but you can set this in the new project wizard.
If you want to add the defines:
Project->Build options->Select the target on the left->Compiler settings->#defines

sodev:
What are you using make for? Are you using CodeBlocks with an external Makefile? Why don't you use CodeBlocks itself to build?

But beside that, CodeBlocks doesn't define anything magically by itself, you have to define it yourself in the proper locations. There is a section in the project properties for defines, if you put your defines there the code completion should pick them up and highlight your code properly. Its a very good idea to define NDEBUG for a release build, without it the c++ standard library runs in debug mode.

dams:
This is about code highlighting. If I switch to debug target, the debug sections stays light compare with the release code.  I don't have a defines tab in project properties, using codeblocks 16.01. The only thing I got is in the Settings menu, under Compiler settings, there's a #defines tab, but if I add DEBUG in there, it doesn't highlight the Debug sections.

BlueHazzard:

--- Quote ---I don't have a defines tab in project properties,
--- End quote ---
read what i have written.... (you don't have this setting when you are using a custom make file. Else you should have one)
The highlighting is a bit complicated. I am not 100% if it works, because this comes from a third party library. In theory it should work when you put the define in the right place (or in the right settings)...

Navigation

[0] Message Index

[#] Next page

Go to full version