Author Topic: Editor defines enlightenments (Debug | Release)  (Read 2643 times)

Offline dams

  • Single posting newcomer
  • *
  • Posts: 3
Editor defines enlightenments (Debug | Release)
« 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 ?
« Last Edit: August 25, 2017, 07:12:57 pm by dams »

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: Editor defines enlightenments (Debug | Release)
« Reply #1 on: August 25, 2017, 07:39:59 pm »
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 ?
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

Offline sodev

  • Regular
  • ***
  • Posts: 497
Re: Editor defines enlightenments (Debug | Release)
« Reply #2 on: August 25, 2017, 07:43:07 pm »
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.

Offline dams

  • Single posting newcomer
  • *
  • Posts: 3
Re: Editor defines enlightenments (Debug | Release)
« Reply #3 on: August 25, 2017, 08:51:28 pm »
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.

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: Editor defines enlightenments (Debug | Release)
« Reply #4 on: August 25, 2017, 09:23:55 pm »
Quote
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)...

Offline dams

  • Single posting newcomer
  • *
  • Posts: 3
Re: Editor defines enlightenments (Debug | Release)
« Reply #5 on: August 25, 2017, 10:28:52 pm »
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.

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: Editor defines enlightenments (Debug | Release)
« Reply #6 on: August 26, 2017, 03:30:19 pm »
Quote
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...

Quote
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.