相关疑难解决方法(0)

如何更改 VS Code 中使用的 C++ 语言标准版本?

我打印了宏的值__cplusplus,发现我的文件是在 Visual Studio Code 中使用 C++98 执行的。我正在使用 CodeRunner 扩展。

如何将其更改为 C++17?

c++ visual-studio-code

16
推荐指数
2
解决办法
5万
查看次数

c ++编译错误'预期';' 在声明结束时使用直接大括号初始化

我对 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)

c++ compiler-errors visual-studio-code c++17

7
推荐指数
2
解决办法
1876
查看次数

错误:此编译器似乎太旧,Eigen 不支持

我正在尝试编译一个包含 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)

我在用:

  • 乌班图20.04
  • Cmake 3.16.3
  • VSCode 编译器 GCC 10.3.1
  • 本征 3.4.90

该问题似乎与 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)

c++ compiler-errors eigen eigen3

4
推荐指数
1
解决办法
4696
查看次数

标签 统计

c++ ×3

compiler-errors ×2

visual-studio-code ×2

c++17 ×1

eigen ×1

eigen3 ×1