News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

How to define specific preprocessor symbols for release/debug target

Started by RK117, August 10, 2015, 07:18:30 AM

Previous topic - Next topic

RK117

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.

scarphin

The exact location is 'Project->Build options->Compiler settings tab->#defines' for your target. If you don't have that there's something wrong.

RK117

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.

LETARTARE

Hello,
you could try
http://forums.next.codeblocks.org/index.php/topic,20000.0.html
Regards

Did not notice that you use Linux !
CB-13834, plugins-sdk-2.25.0 : Collector-2.6.5, AddOnForQt-5.1.2
1- Win7 Business Pack1 64bits : wx-3.2.8, gcc-15.2.0,
2- OpenSuse::Leap-15.6-64bits : wx-3.2.8;gtk3-u, gcc-15.2.0,
=> !! The messages are translated by 'Deepl'

stahta01

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

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++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

RK117

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.