Author Topic: Using compilers in C++17 mode  (Read 7289 times)

Offline pabristow

  • Multiple posting newcomer
  • *
  • Posts: 62
Using compilers in C++17 mode
« on: June 16, 2016, 01:15:54 pm »
I want to use GCC and Clang in C++17 mode by adding -std=c++17.

(This is to maximise the use of constexpr).

There isn't a C++17 option in the Build Options, Compiler options, only C++14

When I add to Other compiler options and Append target options to project options, I get a compile line

g++.exe -Wall -fexceptions -g -std=c++17 -O3 -Wall -std=c++14 -II:\boost_1_61_0_b1 -c J:\Cpp\hellos\hello_boost\hello_boost.cpp -o obj\Debug\hello_boost.o

I expected the added compiler option to be last, but the default?  -std=c++14 is last and so overrides and I'm not getting the option I expect.

  __cplusplus=201402L
GCC 5.3.0

Is this failure to append as I, at least, expect a 'feature' or a bug?

http://forums.codeblocks.org/index.php/topic,20527.msg139644.html#msg139644

suggests that I might have to edit the options_common_warnings.xml

but this sounds a bit scary  :-\

or has anyone done this already?



Offline pabristow

  • Multiple posting newcomer
  • *
  • Posts: 62
Re: Using compilers in C++17 mode
« Reply #1 on: June 16, 2016, 01:29:15 pm »
PS I know I may also need to get GCC 6 to get C++17.

But I'd like to use GCC 6 in 14 and 17 (and 11 modes)

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6956
    • My Best Post
Re: Using compilers in C++17 mode
« Reply #2 on: June 16, 2016, 02:37:57 pm »
Find where you set the option "-std=c++14" and remove it.

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12738
    • Travis build status
Re: Using compilers in C++17 mode
« Reply #3 on: June 16, 2016, 06:06:05 pm »
There are 3 different places:
1. target settings
2. project settings
3. global compiler settings

None of our templates set any of these options as far as I know.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5242
Re: Using compilers in C++17 mode
« Reply #4 on: June 16, 2016, 06:36:35 pm »
note that the latest nightly already support on the gui : -std=c++1z because as fas as i Know c++17 does not exist yet. Who says they will make it in 2017 ...

So gcc already supports some stuff when you use -std==c++1z.

Offline pabristow

  • Multiple posting newcomer
  • *
  • Posts: 62
Re: Using compilers in C++17 mode
« Reply #5 on: June 17, 2016, 06:58:01 pm »
Correct - I had set C++14 in the global settings, but forgotten   :-[

Flexibility is wonderful - except for those still in fumble mode.

But I'm still slightly surprised that "Append target option to project options" didn't seem to have the effect I expected because the global options seemed to be appended last to override both.

But it does what it says on the tin I suppose ?

It this really 'by design' as they always say on another popular site?

But thanks.