Author Topic: Incorrect forced command line compiler option  (Read 4247 times)

Offline Condor

  • Single posting newcomer
  • *
  • Posts: 2
Incorrect forced command line compiler option
« on: April 08, 2020, 07:26:32 am »
Attempting to switch from 17.12 to 20.03 but initial testing fails. Installed setup version that includes mingw on Windows 10. Initial test of HelloWorld failed because the Toolchain executables in compiler settings had incomplete filenames - apparently mingw now includes processor type as part of the filename. For example, gcc is x86_64-w64-mingw32-gcc.exe whereas Code::Blocks expects the older / shorter gcc.exe filename.

With that issue fixed, at least Code::Blocks found the compiler.

HelloWorld still would not compile. The problem appears to be in the that Code::Blocks insists on trying to force the compiler to the C++20 standard with an incorrect command line option. Even with the Settings > Compiler > Global compiler settings > Compiler flags checkmark in the "Have g++ follow the C++17 ICO C++17 language standard" there is still a command line option of  -std=c++20 included when I look at the Build log. There is also a command line option for -std=c++17

This may actually be two problems: 1) why is there a command line option for a c++ standard that is not specified in the Code::Blocks drop down menu? and 2) apparently, if I did want to have c++20 as the language standard, mingw wants the format to be "-std=c++2a" - I get this from the compiler error message in the Build log window - x86_64-w64-mingw32-g++.exe: error: unrecognized command line option '-std=c++20'; did you mean '-std=c++2a'?


There may be some setup item where that -std=c++20 gets pulled into the command line / makefile... but I cannot find it.

Thanks for any suggestions

Here is the complete command line generated, including the erroneous -std command

x86_64-w64-mingw32-g++.exe -fexceptions -Weffc++ -pedantic-errors -pedantic -Wextra -Wall -std=c++17 -g -std=c++20 -Weffc++ -pedantic-errors -Wextra -Wall -std=gnu++17 -Wsign-conversion -Werror  -c E:\Personal\learning\CPP_CodeBlocks\NewProject1\main.cpp -o obj\Debug\main.o

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: Incorrect forced command line compiler option
« Reply #1 on: April 08, 2020, 08:24:47 am »
The places to look for compiler command options:
1) Settings->Compiler -> Select your compiler from the drop down menu
1.1) Compiler settings -> Compiler flags
1.2) Compiler settings -> Other compiler options
2) With an open project Project -> Build options
2.1) Select the project name on the left -> Compiler settings->Compiler flag
2.2) Select the project name on the left -> Compiler settings->Other compiler options
2.3) Select the Build target name on the left -> Compiler settings-> Compiler flag
2.4) Select the Build target name on the left -> Compiler settings-> Other compiler options

Offline StillSvenTmp

  • Single posting newcomer
  • *
  • Posts: 2
Re: Incorrect forced command line compiler option
« Reply #2 on: April 16, 2020, 03:22:38 pm »
Attempting to switch from 17.12 to 20.03 but initial testing fails. Installed setup version that includes mingw on Windows 10. Initial test of HelloWorld failed because the Toolchain executables in compiler settings had incomplete filenames - apparently mingw now includes processor type as part of the filename. For example, gcc is x86_64-w64-mingw32-gcc.exe whereas Code::Blocks expects the older / shorter gcc.exe filename.

Actually, all recent (for a few years already) MinGW-w64 Windows builds, including the one bundled with C::B 20.03, come with both long versions ("x86_64-w64-mingw32-gcc.exe") and short versions ("gcc.exe") of executables that are identical otherwise. So it was the other way around: on 17.12, if you wanted to switch GCC from C::B bundle to a newer one and keep calling it <gcc>, you had to replace 32-bit unique names with the short ones. There should be no such problem on clean install now.

Since I'm also trying to transition to 20.03, including some idiosyncratic setup, I still play around with configuration options. Therefore I can confirm that Hello World example compiles and runs out-of-the-box (albeit after fixing botched compiler detection), using all of the following ways: single-file compile, Empty project and Console application project (C++). Debug build of the last one contains only -Wall, -fexceptions and -g as options (plus -Og? I forget), same as 17.12.

So my best guess is that you have used previously left 17.12 .config file, custom .cbp file or some other custom configuration that includes -std=c++20 flag. Seeing all the other (repeated and conflicting) options that are pulled in, there's definitely some build-up here.

Offline Condor

  • Single posting newcomer
  • *
  • Posts: 2
Re: Incorrect forced command line compiler option
« Reply #3 on: May 27, 2020, 07:44:10 am »
Thanks,
Found a separate install of MinGW on a different drive. Apparently there was some fragment config that was being detected by CB. Uninstalled CB and the other MinGW, restarted system and did fresh install of CB 20.03.
It now appears to be working!