Author Topic: How to define specific preprocessor symbols for release/debug target  (Read 9348 times)

Offline RK117

  • Single posting newcomer
  • *
  • Posts: 3
Hello,

I want to define preprocessor symbols for the debug target and other ones for the release target. Many topics speak how to define symbols into Project->Build options...->Debug/Target -> "defines" tabs... But I have no "#defines" tab (I use Code::Blocks 13:12 under Linux). There is only "Custom variables" and if put the definition of my symbols there, compiling ignores them. The only "#defines" tab is in Settings->Compiler...->Global compiler settings->Compiler settings->#defines. But defining my symbols there is not specific to a target mode.

I thought it was possible to define preprocessor symbols for each target mode. Perhaps I'm wrong. Maybe there is something I don't understand.
For instance, I'd like to define

#define  CODEFLAG=1  // Debug target
#define  CODEFLAG=2  // Release target

I can modify them by hand but if I forget...

Can you help me to solve my problem or just to suggest an idea ? Thanks in advance.

Offline scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: How to define specific preprocessor symbols for release/debug target
« Reply #1 on: August 10, 2015, 07:49:05 am »
The exact location is 'Project->Build options->Compiler settings tab->#defines' for your target. If you don't have that there's something wrong.

Offline RK117

  • Single posting newcomer
  • *
  • Posts: 3
Re: How to define specific preprocessor symbols for release/debug target
« Reply #2 on: August 10, 2015, 08:54:06 am »
Thanks for your answer. I found my problem.

My project is based on Qt-5 and I use my own Makefile. Thus in "Project settings" I selected "This is a custom Makefile". And when this checkbox is checked, the tabs "Compiler settings", "Linker settings" and "Search directories" are removed. I forgot that I use a customized makefile. I feel so stupid... It was so obvious.

Now I have to learn compiling my Qt-5 project with a auto-generated Makefile. I didn't it before this day because the compiler complains about missing files. I used a customized Makefile to bypass the problem. Now, I have no choice.

Thanks again.

Offline LETARTARE

  • Lives here!
  • ****
  • Posts: 531
  • L'ami de l'homme.The friend of man.
    • LETARTARE
Re: How to define specific preprocessor symbols for release/debug target
« Reply #3 on: August 10, 2015, 09:08:48 am »
Hello,
you could try
http://forums.codeblocks.org/index.php/topic,20000.0.html
Regards

 Did not notice that you use Linux !
« Last Edit: August 10, 2015, 11:18:36 am by LETARTARE »
CB-13483, plugins-sdk-2.25.0 : Collector-2.0.0, AddOnForQt-3.9.1
1-Win7 Business Pack1 64bits : wx-3.2.4, gcc-8.1.0,
2-OpenSuse::Leap-15.4-64bits : wx-3.2.4;gtk3, gcc-8.2.1,
=> !! The messages are translated by Deepl

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: How to define specific preprocessor symbols for release/debug target
« Reply #4 on: August 10, 2015, 07:09:06 pm »
Hello,

I want to define preprocessor symbols for the debug target and other ones for the release target. Many topics speak how to define symbols into Project->Build options...->Debug/Target -> "defines" tabs... But I have no "#defines" tab (I use Code::Blocks 13:12 under Linux). There is only "Custom variables" and if put the definition of my symbols there, compiling ignores them. The only "#defines" tab is in Settings->Compiler...->Global compiler settings->Compiler settings->#defines. But defining my symbols there is not specific to a target mode.

I thought it was possible to define preprocessor symbols for each target mode. Perhaps I'm wrong. Maybe there is something I don't understand.
For instance, I'd like to define

#define  CODEFLAG=1  // Debug target
#define  CODEFLAG=2  // Release target

I can modify them by hand but if I forget...

Can you help me to solve my problem or just to suggest an idea ? Thanks in advance.

You can do this even if you use a custom makefile.
But, you need to edit the make command to do it.

I did it once in the past; I will see if I can find where I did it.
It will likely take a couple of days before I have time to look for it.

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline RK117

  • Single posting newcomer
  • *
  • Posts: 3
Re: How to define specific preprocessor symbols for release/debug target
« Reply #5 on: August 11, 2015, 01:30:11 am »
Thank you very much. Your answers was very helpfull. I solved my problem.

I was looking for a solution at a bad location. As Stahta01 said, I can use my own Makefile  and I have just to define my symbols within the pro file of Qt via QMAKE_CXXFLAGS_DEBUG and QMAKE_CXXFLAGS_RELEASE. Sometimes the good way is just under your feet...

Please consider my problem as solved. Thank you everybody. It's thanks to you.