最近在研究正则表达式的时候,在vscode调试代码,包含了
#include <bits/stdc++.h>
#include <regex>
头文件,编译的时候出现错误,提示#error This file requires compiler and
library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
同时显示Unable to open 'c++0x_warning.h,这个头文件。
解决方法是在tasks.json文件里的args参数项里增加一项"-std=c++11"
增加前:"args": ["-g","${file}","-o","${fileBasenameNoExtension}.exe"],
增加后:"args": ["-g","-std=c++11","${file}","-o","${fileBasenameNoExtension}.exe"],
编译顺利通过,哈哈
本文详细介绍了在使用VSCode进行C++编程时遇到的编译错误,特别是与C++11标准相关的错误。文章分享了如何在tasks.json文件中正确设置编译参数,以启用C++11支持,成功解决了无法识别C++11标准和头文件的问题。
90





