在mingw g 4.7.2中未申报
decltype undeclared in mingw g++ 4.7.2
本文关键字:mingw 更新时间:2023-10-16
出于某种原因或其他原因,当试图在mingw
上编译G 中的以下代码#include <iostream>
#include <string>
#include <cctype>
int main( int argc, char **argv )
{
std::string s( "Hello, World!" );
decltype( s.size( ) ) punct_cnt = 0;
for ( auto c : s )
{
if ( ispunct( c ) )
++punct_cnt;
}
std::cout << punct_cnt << " punctuation characters in " << s << std::endl;
return 0;
}
我得到以下错误
test.cpp: In function 'int main(int, char**)':
test.cpp:9:23: error: 'decltype' was not declared in this scope
test.cpp:9:25: error: expected ';' before 'punct_cnt'
test.cpp:11:13: error: 'c' does not name a type
test.cpp:17:2: error: expected ';' before 'std'
test.cpp:17:15: error: 'punct_cnt' was not declared in this scope
test.cpp:19:2: error: expected primary-expression before 'return'
test.cpp:19:2: error: expected ')' before 'return'
我已经检查过,G 编译器的版本为4.7.2,除了将decltype
更改为std::string::size_type
外,任何人都可以解决任何想法?
decltype
是C 11功能。您需要以这种方式致电GCC
g++ -std=c++11
相关文章:
- 在VS代码中交叉编译Windows与Linux上的MinGW的SDL程序
- 如何将C++中的库和头与MinGW一起使用
- 为什么与常规GCC不同,即使有"学究性错误",MinGW-GCC也能容忍丢失的返回类型
- 无法在windows上使用mingw将sqlite3与c连接
- MinGw 无法从 cmake 编译测试文件
- MSYS2 MinGW程序包中缺少grpc_cpp_plugin协议
- Mingw-64 在构建和安装后不会编译 openCV 代码
- 安装MinGW后C++编译器不起作用?
- 当我尝试通过 mingw 使用 CMake 和 SFML 库编译项目时出错
- 如何在 Linux for Windows 上通过 MinGW 构建静态 ICU 的 Boost
- 使用 MinGW 在 Windows 上安装 GMP 时出错
- VSCode - C++ - MinGW 编译器的问题
- C++:如何在Windows 10上使用编译器MinGW 9.2.0安装OpenCV
- MINGW - 正确运行函数所需的 cdecl
- 尝试在Windows上执行C++时出错(通过MinGW编译)
- 分段 Linux Ubuntu 中的 g++ 错误,但在 Windows 中的 g++/MingW 中,在 C++ 中打
- SFML 库 - 在 MinGW 构建期间未找到错误
- 使用 MinGW 在 Windows 上构建 GLEW 时遇到问题
- 如何使用命令提示符、记事本和 MinGW 使用主文件、头文件和实现文件编译C++程序?
- 如何构建一个 setup.py 来编译C++使用 Python、pybind11 和 Mingw-w64 的扩展?