News:

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

Main Menu

compiler options automatically (untwantedly) converted to #defines

Started by alle_meije, March 04, 2011, 10:17:13 AM

Previous topic - Next topic

alle_meije

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

MortenMacFly

Quote from: alle_meije on March 04, 2011, 10:17:13 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.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

ptDev

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.

Jenna

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

thomas

Yup, this has annoyed me big time in the past. But once you're used to it, it's actually ok.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

ptDev

Quote from: jens on March 04, 2011, 11:59:06 AM
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. :)