c++ - clang++ 3.1 但在 Lion Xcode 4.3.3 上没有 `cxx_lambdas`

标签 c++ lambda c++11 xcode4.3 clang++

这与 Clang 3.1 and C++11 support status 有关,但我在那里找不到答案,我在这里更具体:cxx_lambdas support on clang 3.1 on my exact setup。

我在 OSX Lion 10.7.4 上安装了 Xcode 4.3.3 和最新的命令行工具包(2012 年 6 月 11 日)。我现在有了 clang++ 3.1 版:

llins@jupara:~/projects/tests/C++11$ clang++ -v
Apple clang version 3.1 (tags/Apple/clang-318.0.61) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin11.4.0
Thread model: posix

基于 http://clang.llvm.org/cxx_status.html ,我期待功能 cxx_lambdas 可用,但这不是我得到的:

llins@jupara:~/projects/tests/C++11$ make
clang++ -std=c++11 -stdlib=libc++ test_clang_features.cpp -o test_clang_features

llins@jupara:~/projects/tests/C++11$ ./test_clang_features 
FAILED feature tests: 
__has_feature(cxx_constexpr) .................................. FAILED
__has_feature(cxx_generalized_initializers) ................... FAILED
__has_feature(cxx_inheriting_constructors) .................... FAILED
__has_feature(cxx_lambdas) .................................... FAILED
__has_feature(cxx_local_type_template_args) ................... FAILED
__has_feature(cxx_unrestricted_unions) ........................ FAILED
__has_feature(cxx_user_literals) .............................. FAILED

这是我为获取此报告而运行的代码:

#include <iostream>
using namespace std;
void main()
{
    cout << "FAILED feature tests: " << endl;

//  testing all features cxx_???? described in (only 3 shown here):
//      http://llvm.org/releases/3.1/tools/clang/docs/LanguageExtensions.html#cxx11

#if !__has_feature(cxx_generalized_initializers)
    cout << "__has_feature(cxx_generalized_initializers) ................... FAILED" << endl;
#endif
#if !__has_feature(cxx_implicit_moves)
    cout << "__has_feature(cxx_implicit_moves) ............................. FAILED" << endl;
#endif
//... analogous tests ...
#if !__has_feature(cxx_lambdas)
    cout << "__has_feature(cxx_lambdas) .................................... FAILED" << endl;
#endif
}

注意 cxx_lambdas 失败了。以下是已测试功能的完整列表:

cxx_access_control_sfinae cxx_alias_templates cxx_alignas
cxx_attributes cxx_auto_type cxx_constexpr cxx_decltype
cxx_default_function_template_args cxx_defaulted_functions
cxx_delegating_constructors cxx_deleted_functions cxx_exceptions
cxx_explicit_conversions cxx_generalized_initializers
cxx_implicit_moves cxx_inheriting_constructors cxx_inline_namespaces
cxx_lambdas cxx_local_type_template_args cxx_noexcept
cxx_nonstatic_member_init cxx_nullptr cxx_override_control
cxx_range_for cxx_raw_string_literals
cxx_reference_qualified_functions cxx_rtti cxx_rvalue_references
cxx_static_assert cxx_strong_enums cxx_trailing_return
cxx_unicode_literals cxx_unrestricted_unions cxx_user_literals
cxx_variadic_templates

为什么 cxx_lambdas 在 clang++ 3.1 的设置中不可用?

最佳答案

Xcode 4.4+ 将提供 Lambada 支持
正如 ildjarn 指出的那样,Apple 的 clang/llvm 发行版是定制的......

关于c++ - clang++ 3.1 但在 Lion Xcode 4.3.3 上没有 `cxx_lambdas`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11173121/

相关文章:

python - 在 Python 3.2 中, "lambda"是否被视为 "keyword,"和 "operator"或两者?

c++ - 在 G++ 编译命令中包含 -std=c++0x 有什么意义?

c++ - 将第一个元素移动到队列的后面

c++ - 共享 DLL 中是否可能存在多个单例实例?

python - Map对象转换为列表后清空自身

c# - IEnumerable<T>.ToLookup<TKey, TValue>

c++ - 为介子设置正确的编译器

c++,位图不会显示?

c++ - 多字符持续警告

C++ 模板语法