User forums > Using Code::Blocks
How to define specific preprocessor symbols for release/debug target
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.codeblocks.org/index.php/topic,20000.0.html
Regards
Did not notice that you use Linux !
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.
--- End quote ---
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.
Navigation
[0] Message Index
[#] Next page
Go to full version