Author Topic: compiler options automatically (untwantedly) converted to #defines  (Read 4861 times)

Offline alle_meije

  • Multiple posting newcomer
  • *
  • Posts: 29
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

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: compiler options automatically (untwantedly) converted to #defines
« Reply #1 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.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline ptDev

  • Almost regular
  • **
  • Posts: 222
Re: compiler options automatically (untwantedly) converted to #defines
« Reply #2 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.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: compiler options automatically (untwantedly) converted to #defines
« Reply #3 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" ).

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: compiler options automatically (untwantedly) converted to #defines
« Reply #4 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.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline ptDev

  • Almost regular
  • **
  • Posts: 222
Re: compiler options automatically (untwantedly) converted to #defines
« Reply #5 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. :)