Author Topic: Error: unrecognized command line option '-std=gnu++20'; did you mean '-std=gnu  (Read 17873 times)

Offline istvankurucz

  • Single posting newcomer
  • *
  • Posts: 2
I've just downloaded the newest version (20.03) and if I want to build a project I always get this error.

||=== Build: Debug in eutazas (compiler: GNU GCC Compiler) ===|
||error: unrecognized command line option '-std=gnu++20'; did you mean '-std=gnu++2a'?|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|


Please help me how can I fix that.

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1557
It depends on what compiler did you install. If it is GCC, with versions 9 and earlier you must use "-std=gnu++2a". See:

https://gcc.gnu.org/projects/cxx-status.html

EDIT: there is a mismatch in the options used for GCC 9, the compiler plugin generates -std=gnu++20 when it should generate -std=gnu2a. As a workaround you can uncheck the C++20 option and add -std=gnu++2a in "Other compiler options"

I have created a ticket with a patch: https://sourceforge.net/p/codeblocks/tickets/1006/
« Last Edit: August 13, 2020, 07:21:10 pm by Miguel Gimenez »

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1557
As a workaround you can uncheck the C++20 option in "Project -> Build options -> Compiler settings -> Compiler flags" and add a line "-std=gnu++2a" (without the quotes) in "Project -> Build options -> Compiler settings -> Other compiler options"

You can also edit the flag clicking on it with the right mouse button.

Offline istvankurucz

  • Single posting newcomer
  • *
  • Posts: 2
I don't have c++20 option but I added a new flag according to you. I also tried to add the patch which was created by you and it didn't work either. I don't know why it is happening. I haven't had any problems with the compilers so far.

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1557
After applying the patch to C::B sources you must compile the compiler plugin so it updates the resources zip file, and then you must call the relevant update script so the zip is copied to the output folder.

The C++20 options are added for GCC 9 and GCC 10, so you should have it. Also, if you don't have a C++20 option, how did you get the "-std=gnu++20" option added?