Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: alle_meije on March 04, 2011, 10:17:13 am

Title: compiler options automatically (untwantedly) converted to #defines
Post by: alle_meije on March 04, 2011, 10:17:13 am
Hello,

I am using the boost libraries for my software, and also some of the "sandboxes" from http://beta.boost.org/community/sandbox.html
To compile them the info file http://svn.boost.org/svn/boost/sandbox/variadic_templates/README.compiler_requirements.txt says that

  In addition, to avoid problems with some boost header files, the compiler needs to be called with the:
    -DBOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
  option

I added this option for my project in 'projects'->'build options'->'compiler settings'->'other options' (where other flags like '-fPIC' and '-march=native' can be set as well), for both the Debug and Release targets.

But when I go back to the same tab, the 'other options' tab is empty, and the tab '#defines' has the value  DBOOST_MPL_CFG_NO_PREPROCESSED_HEADERS (so the option that I gave to 'other options', but without the hyphen in front)

I like it when settings like these are handled automatically (who'd go back to manually editing Makefiles) but in this case I need a compiler option not a #define. Does anyone know how to force this?

Many thanks
Title: Re: compiler options automatically (untwantedly) converted to #defines
Post by: MortenMacFly on March 04, 2011, 10:32:00 am
Does anyone know how to force this?
You are doing something wrong here. A #define is not an "other option". To add a compiler #define, go to the #defines tab and add "BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS". Notice the missing "-D" which is the compiler directive for a #define. C::B will handle this accordingly.
Title: Re: compiler options automatically (untwantedly) converted to #defines
Post by: ptDev on March 04, 2011, 11:32:06 am
Like MortenMacFly said, there is no need to "force" anything.
Different settings are just used differently:

"Other option" : whatever you write in this box is passed on to the compiler as a command line option, as you type it.
"#defines" : you write symbols (e.g., ENABLE_THIS or SOME_FLAG=1) and these symbols are translated to the -D syntax (-DENABLE_THIS and -DSOME_FLAG=1 per examples), and then passed on to the compiler in the command line.

Use whatever approach you're more comfortable with, but it's advisable to separate #defines from compiler arguments for clarity.
Title: Re: compiler options automatically (untwantedly) converted to #defines
Post by: Jenna on March 04, 2011, 11:59:06 am
Like MortenMacFly said, there is no need to "force" anything.
Different settings are just used differently:

"Other option" : whatever you write in this box is passed on to the compiler as a command line option, as you type it.
"#defines" : you write symbols (e.g., ENABLE_THIS or SOME_FLAG=1) and these symbols are translated to the -D syntax (-DENABLE_THIS and -DSOME_FLAG=1 per examples), and then passed on to the compiler in the command line.

Use whatever approach you're more comfortable with, but it's advisable to separate #defines from compiler arguments for clarity.
That's only partly right.
If you add a #define ("-Dxxx") to the Other options, C::B automagically moves it to the #defines-tab (without the "-D" ).
Title: Re: compiler options automatically (untwantedly) converted to #defines
Post by: thomas on March 04, 2011, 04:43:19 pm
Yup, this has annoyed me big time in the past. But once you're used to it, it's actually ok.
Title: Re: compiler options automatically (untwantedly) converted to #defines
Post by: ptDev on March 04, 2011, 10:28:18 pm
That's only partly right.
If you add a #define ("-Dxxx") to the Other options, C::B automagically moves it to the #defines-tab (without the "-D" ).

I always split them, so I never noticed this. Nice. :)