我打印了宏的值__cplusplus,发现我的文件是在 Visual Studio Code 中使用 C++98 执行的。我正在使用 CodeRunner 扩展。
如何将其更改为 C++17?
我对 C++ 非常陌生,正在学习我的第一个教程,当我尝试编译课程中的代码时,出现以下错误:
expected ';' at end of declaration
int x{ }; // define variable x to hold user input (a...
^
;
Run Code Online (Sandbox Code Playgroud)
我试图运行的程序的完整代码:
#include <iostream> // for std::cout and std::cin
int main()
{
std::cout << "Enter a number: ";
int x{ };
std::cin >> x;
std::cout << "You entered " << x << '\n';
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我在 Macbook Pro 上使用 Visual Studio Code (v.1.46.1),带有 Microsoft C/C++ 扩展 ( https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools )。
我的编译器是 Clang:
Apple clang version 11.0.3 (clang-1103.0.32.62)
Target: …Run Code Online (Sandbox Code Playgroud) 我正在尝试编译一个包含 eigen 库的项目,但出现此错误:
In file included from /home/--/--/--/Eigen/Core:19,
from /home/--/--/--/Eigen/Geometry:11,
from /usr/include/rl-0.7.0/rl/math/Transform.h:34,
from /home/--/--/--/example.cpp:2:
/home/--/--/--/Eigen/src/Core/util/Macros.h:674:2: error: #error This compiler appears to be too old to be supported by Eigen
674 | #error This compiler appears to be too old to be supported by Eigen
| ^~~~~
Run Code Online (Sandbox Code Playgroud)
我在用:
该问题似乎与 Macros.h 文件中的这些行有关:
// The macros EIGEN_HAS_CXX?? defines a rough estimate of available c++ features
// but in practice we should not rely on …Run Code Online (Sandbox Code Playgroud)