Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: RK117 on August 10, 2015, 07:18:30 am

Title: How to define specific preprocessor symbols for release/debug target
Post by: RK117 on August 10, 2015, 07:18:30 am
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.
Title: Re: How to define specific preprocessor symbols for release/debug target
Post by: scarphin 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.
Title: Re: How to define specific preprocessor symbols for release/debug target
Post by: RK117 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.
Title: Re: How to define specific preprocessor symbols for release/debug target
Post by: LETARTARE on August 10, 2015, 09:08:48 am
Hello,
you could try
http://forums.codeblocks.org/index.php/topic,20000.0.html (http://forums.codeblocks.org/index.php/topic,20000.0.html)
Regards

 Did not notice that you use Linux !
Title: Re: How to define specific preprocessor symbols for release/debug target
Post by: stahta01 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.
Title: Re: How to define specific preprocessor symbols for release/debug target
Post by: RK117 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.