User forums > Using Code::Blocks

Error compiling program with the option C++20

(1/2) > >>

tumanovalex:
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;
}
--- End code ---
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))

--- End code ---
This program compiles without errors in Visual Studio 2022, but I work more often in CodeBlocks.
Please help me solve the problem.

Grit Clef:
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.

tumanovalex:
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?

tumanovalex:
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.

user2024:

--- Quote from: tumanovalex on February 04, 2024, 10:12:51 am ---My suggestion to include a modern compiler in the distribution is stupid, because compiler versions change very quickly.

--- End quote ---
I don't think it's that stupid. A compiler that is actual at the time of release wouldn't be asking too much.

Navigation

[0] Message Index

[#] Next page

Go to full version