在Netbeans中配置C++ 11

use*_*653 17 c++ netbeans-7 c++11

我使用的是Netbeans 7.2,我使用Cygwin设置下载了GCC 4.7.我还将目录添加到PATH中,我相信在NetBeans中正确配置了这些设置.无论我做什么,我都会收到错误:-std = c ++ 11无法识别.

从我需要使用的源代码中,这一行特别引起了问题:

using size_type = long unsigned int;
Run Code Online (Sandbox Code Playgroud)

这是特定于c ++ 11语法吗?

Fer*_*czi 27

使用GCC 4.7.2,如果使用-std = c ++ 11,它将编译

C:\Users\ferenc>type using_test.cpp
#include <iostream>

using size_type = long unsigned int;

int main(int argc,char* argv[])
{
        std::cout<<sizeof(size_type)<<std::endl;
        return 0;
}

C:\Users\ferenc>g++ -std=c++11 using_test.cpp

C:\Users\ferenc>a.exe
4

C:\Users\ferenc>
Run Code Online (Sandbox Code Playgroud)
  1. 确保已将NetBeans指向正确的MinGW版本.要做到这一点,去Project Properties > Build > Tool Collection > ... > Tool Collection Manager在那里你可以将路径设置为适当的G ++版本.

  2. 确保已设置正确的编译器选项:

    Project Properties > Build > C++ Compiler >

    Compilation Line > Additional Options

    设置为: -std=c++11


Man*_*ddy 5

更简单的步骤:

  1. 打开项目
  2. 文件菜单>项目属性
  3. 在Build> C++ Compiler> C++ Standard> C++ 14/C++ 11下