Code::Blocks Forums
User forums => Using Code::Blocks => Topic started by: dams on August 25, 2017, 07:00:18 pm
-
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 ?
-
Are you talking about passing the right parameter to the compiler, or are you talking about code highlighting?
Is there a preprocessor variable defined in Code::Blocks for Debug / Release target ?
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
-
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.
-
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.
-
I don't have a defines tab in project properties,
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)...
-
Yep, I use a custom makefile as I use autotools to generate them. So I understand there's no build-in DEBUG variable. I can use a common define header file for that I suppose.
-
Yep, I use a custom makefile as I use autotools to generate them.
If you use custom makefile codeblocks is only a better text editor. The Code completion and highlighting has absolute no information about your build process so it can not do its work...
I can use a common define header file for that I suppose.
exactly. The problem ?was? that the highlighting for preprocessor sections ?was? only per file (and compiler options). I don't know if it works now over multiple files.