User forums > Using Code::Blocks
Overide general compiler settings by project settings
(1/1)
Kromitvs:
Windows XP SP2
CB_20070810_rev4365_win32
G++
Newbie :P
Hello,
I have my general compiler settings (Settings->Compiler and Debugger...) set to -g -Wall -pedantic -ansi. It's what I generally use.
But now I'm working with some source code which only compiles without -ansi and -pedantic.
So I would like to configure only this project to use this settings.
How do I do that?
I've tried changing Build options for Project Only, and selecting and deselecting those options, but nothing seems to work. Couldn't find help in the manual, wiki, or here...
Errors I receive with those options enabled:
--- Code: ---..\IBPP core\ibase.h:100: error: ISO C++ does not support `long long'
..\IBPP core\ibase.h:101: error: ISO C++ does not support `long long'
..\IBPP core\_ibpp.cpp:: In member function `ibpp_internals::GDS* ibpp_internals::GDS::Call()':
..\IBPP core\_ibpp.cpp:139: error: `putenv' undeclared (first use this function)
..\IBPP core\_ibpp.cpp:139: error: (Each undeclared identifier is reported only once for each function it appears in.)
:: === Build finished: 4 errors, 0 warnings ===
--- End code ---
Thanks for all your help!
EDIT: since I can have different settings for Debug and Release, is there a way to set all projects/this project settings? Or only for this project?
MortenMacFly:
--- Quote from: Kromitvs on August 13, 2007, 12:37:24 am ---How do I do that?
--- End quote ---
There are 3 places where to adjust compiler/linker flags:
1.) Within the global compiler options (Settings -> Compiler and Debugger)
2.) Within the project settings (at project level)
3.) Within the project's target settings (at target level)
You can choose to override any existing compiler/linker flags at target level like the following:
a) append new flags
b) prepend new flags
c) overwrite any existing (ignore any existing -> e.g. from project level)
So you can finetune nicely what you have in mind: Place the pedantic and ansi flag only at target level where it's required and let it append (or prepend if you like).
--- Quote from: Kromitvs on August 13, 2007, 12:37:24 am ---
--- Code: ---..\IBPP core\_ibpp.cpp:139: error: `putenv' undeclared (first use this function)
--- End code ---
--- End quote ---
Make sure you also take care of that, too. That's a diferent story (seems like a missing include to me...).
With regards, Morten.
Kromitvs:
Thanks Mortem!
But... I still can't do it (and I know I'm missing something really simple! :( )
So, by steps:
global compiler options (Settings -> Compiler and Debugger): -g -Wall -pedantic -ansi
project settings (at project level): nothing selected in (Build option... -> Compiler settings)
The policy is set to "use project options only"; although that is grayed out and I wouldn't know how to change it;
project's target settings (at target level). Target is Debug. nothing selected in (Build option... -> Compiler settings)
Policy is "use project options only" (and I've tryed the other 3).
I always get the same error messages.
If I go to (Settings -> Compiler and Debugger) and remove -ansi -pedantic, they go way (sorry for the short explanation, newbie at C++ too :) .
Thanks again!
MortenMacFly:
--- Quote from: Kromitvs on August 15, 2007, 02:33:20 am ---global compiler options (Settings -> Compiler and Debugger): -g -Wall -pedantic -ansi
--- End quote ---
That's a very bad place to setup these compiler switches. This would mean you *always* compile a debug version f. ex..
Remove all those from there and from project ooptions.
--- Quote from: Kromitvs on August 15, 2007, 02:33:20 am ---project settings (at project level): nothing selected in (Build option... -> Compiler settings)
The policy is set to "use project options only"; although that is grayed out and I wouldn't know how to change it;
--- End quote ---
As I said: This is possible on target level only. We use the same UI dialog for each of these 3 (different) settings and gray out what's not appropriate.
- place "-Wall" at project level
- place "-g" at debug target level (appending this option, or leave the default setting whcih is prepending IMHO)
- place "-pedantic -ansi" only at e.g. release target level
If "-pedantic -ansi" doesn't work at all simply remove it completely.
BTW: There is also a WiKi article about setting up project options which will guide you even more in that direction. Search for it! ;-)
With regards, Morten.
Kromitvs:
Thanks for your help! I'll read the wiki with more attention!
(sorry for delaying my answer, some work came up)
Navigation
[0] Message Index
Go to full version