Author Topic: Error compiling program with the option C++20  (Read 1583 times)

Offline tumanovalex

  • Multiple posting newcomer
  • *
  • Posts: 23
Error compiling program with the option C++20
« on: February 04, 2024, 12:01:12 am »
Hello!
Installed codeblocks-20.03-32bit-mingw-32bit-setup.exe . In a simple program:
Code
#include <iostream>
#include <filesystem>
#include <map>
#include <string>

using namespace std;

namespace fs = filesystem;

int main()
{
  setlocale(LC_ALL, "Russian");
  map <string, unsigned int> map_ext;
  for (const fs::directory_entry& dir_entry : fs::recursive_directory_iterator("N:\\TestProgramExt\\"))
  {
    if (fs::is_regular_file(dir_entry))
    {
      string ext = fs::path(dir_entry).extension().string();
      ++map_ext[ext];
    }
  }
  for (auto&& [ext, num] : map_ext)
    std::cout << ext << "\t" << num << std::endl; 
  std::cin.get();
  return 0;
}
I get errors when installing compilation options (C++2020 standard):
Code
-------------- Build: Debug in cbCppStudy (compiler: GNU GCC Compiler)---------------

mingw32-g++.exe -Wall -fexceptions -std=gnu++20  -c N:\MyProgramming\cppStudy\cppStudy.cpp -o obj\Debug\cppStudy.o
mingw32-g++.exe  -o bin\Debug\cbCppStudy.exe obj\Debug\cppStudy.o   
mingw32-g++.exe: error: unrecognized command line option '-std=gnu++20'; did you mean '-std=gnu++2a'?
Process terminated with status 1 (0 minute(s), 0 second(s))
1 error(s), 0 warning(s) (0 minute(s), 0 second(s))
 
-------------- Build: Debug in cbCppStudy (compiler: GNU GCC Compiler)---------------

mingw32-g++.exe -Wall -fexceptions -std=c++20  -c N:\MyProgramming\cppStudy\cppStudy.cpp -o obj\Debug\cppStudy.o
mingw32-g++.exe  -o bin\Debug\cbCppStudy.exe obj\Debug\cppStudy.o   
mingw32-g++.exe: error: unrecognized command line option '-std=c++20'; did you mean '-std=c++2a'?
Process terminated with status 1 (0 minute(s), 0 second(s))
1 error(s), 0 warning(s) (0 minute(s), 0 second(s))
This program compiles without errors in Visual Studio 2022, but I work more often in CodeBlocks.
Please help me solve the problem.

Offline Grit Clef

  • Multiple posting newcomer
  • *
  • Posts: 61
  • Where there is a will, there is a way.
Re: Error compiling program with the option C++20
« Reply #1 on: February 04, 2024, 06:32:43 am »
What's Your GCC Version? That's not related to CodeBlocks, but Your compiler. GCC, 10 and higher, have an acceptable support for C++20.
-Windows 7, 32-bit
-CodeBlocks r13490, gcc 13.2.0, debug version

Offline tumanovalex

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: Error compiling program with the option C++20
« Reply #2 on: February 04, 2024, 09:45:13 am »
Thanks for the reply. The version of g++ 8.1 supplied in this distribution. Is it possible to make sure that the distribution includes the most modern version MinGW? In order not to look for the compiler in other places, but to use it immediately together with code blocks?

Offline tumanovalex

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: Error compiling program with the option C++20
« Reply #3 on: February 04, 2024, 10:12:51 am »
Thank you very much for the answer, I found a modern compiler and everything worked out. My suggestion to include a modern compiler in the distribution is stupid, because compiler versions change very quickly.

Offline user2024

  • Single posting newcomer
  • *
  • Posts: 6
Re: Error compiling program with the option C++20
« Reply #4 on: February 09, 2024, 11:16:14 pm »
My suggestion to include a modern compiler in the distribution is stupid, because compiler versions change very quickly.
I don't think it's that stupid. A compiler that is actual at the time of release wouldn't be asking too much.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7592
    • My Best Post
Re: Error compiling program with the option C++20
« Reply #5 on: February 10, 2024, 12:59:07 am »
My suggestion to include a modern compiler in the distribution is stupid, because compiler versions change very quickly.
I don't think it's that stupid. A compiler that is actual at the time of release wouldn't be asking too much.

From https://gcc.gnu.org/releases.html
gcc 8.5 was released on May 14, 2021
Therefore, I think the question is not really a good one. Edit: ?8.1? was the version packaged by the third party at the time CB was getting ready for release. And, for good reason the do not wish to change it after the CB goes into something like a feature freeze used by other projects.

Edit: But, I have always maintained that releasing an Compiler with CB was not worth the effort; but, the CB Dev Team has maintained it is needed by the schools that choose CB.

Tim S.
« Last Edit: February 10, 2024, 01:03:30 am by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org