如何启用Codelite中的C ++ 11功能 [英] How to Enable C++11 Features in Codelite

查看:178
本文介绍了如何启用Codelite中的C ++ 11功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下代码在Xcode 5和Visual Studio 2013中编译和运行。我有兴趣尝试Codelite,但Codelite不会编译以下程序(一个问题,因为我在我的项目中使用scoped枚举)。根据我的理解,Codelite使用与Xcode相同的编译器。

The following code compiles and runs in Xcode 5 and in Visual Studio 2013. I am interested in trying out Codelite, but Codelite will not compile the following program (a problem since I am working with scoped enums in my project). As far as I understand it, Codelite is using the same compiler as Xcode.

每个C ++ 11的代码是否有效?为什么Codelite无法编译它?

Is the code valid per C++11? Why is Codelite unable to compile it?

#include <iostream>

namespace abc
{
    namespace xyz
    {
        enum class SampleEnum
        {
            SomeValue = 0,
            SomeOtherValue = 1
        };
    }
}

int main(int argc, char **argv)
{
    abc::xyz::SampleEnum e = abc::xyz::SampleEnum::SomeValue;
    return 0;
}

这是Codelite的构建输出。如果它是乱码,它在变量的实例化和说期望一个类或命名空间指向单词SampleEnum。

Here is the build output from Codelite. In case it's garbled, it's pointing to the word "SampleEnum" in the instantiation of the variable and saying "expected a class or namespace".

/bin/sh -c 'make -j8 -e -f  Makefile'
----------Building project:[ ClangTest - Debug ]----------
codelite-cc /usr/bin/clang++   -c  "/Users/xxx/Desktop/Test/ClangTest/main.cpp" -g -O0 -Wall  -o ./Debug/main.cpp.o -I. -I.
/Users/xxx/Desktop/Test/ClangTest/main.cpp:7:8: warning: scoped enumerations are a C++11 extension [-Wc++11-extensions]
                enum class SampleEnum
                     ^
/Users/xxx/Desktop/Test/ClangTest/main.cpp:17:40: error: expected a class or namespace
    abc::xyz::SampleEnum e = abc::xyz::SampleEnum::SomeValue;
                             ~~~~~~~~~~^
1 warning and 1 error generated.
make[1]: *** [Debug/main.cpp.o] Error 1
make: *** [All] Error 2
2 errors, 1 warnings


推荐答案

有必要将-std = c ++ 11传递给编译器以启用C ++ 11功能。下面是在Codelite中执行此操作的步骤:

It is necessary to pass -std=c++11 to the compiler to enable C++11 features. Here are the steps to do so in Codelite:


  • 在工作区视图中右键单击项目。

  • 选择此弹出式菜单底部附近的设置。通用设置 - >编译器 - > C ++编译器选项

  • 单击分号分隔的编译器开关列表以显示缺省值并单击缺省值。

  • 点击-std = c ++ 11的复选框。

  • Right click on the project in the workspace view.
  • Select Settings near the bottom of this pop-up menu. Common Settings->Compiler->C++ Compiler Options
  • Click into the semicolon delimited list of compiler switches to reveal elipses and click on the elipses.
  • Click the checkbox for -std=c++11

这篇关于如何启用Codelite中的C ++ 11功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆