微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在Xcode 4.5中,“C标准库”和“C语言方言”的“编译器默认”是什么?

Xcode 4.5中“C标准库”和“C语言方言”的“编译器认值”有什么价值?

我的猜测是libstdc和GNU 98,但澄清一下会很好.

Xcode 4.5 release notes

Projects created using this Xcode release use the new libc++
implementation of the standard C++ library. The libc++ library is
available only on iOS 5.0 and later and OS X 10.7 and later. 12221787

To enable deployment on earlier releases of iOS and OS X in your
project, set the C++ Standard Library build setting to libstdc++ (Gnu
C++ standard library).

我注意到创建一个新项目显式设置GNU 11和libc,但“编译器认”可能是其他东西.

解决方法:

以下是了解最佳方法

 #include <iostream>

int main()
{
#ifdef _LIBCPP_VERSION
    std::cout << "Using libc++\n";
#else
    std::cout << "Using libstdc++\n";
#endif
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#if __cplusplus == 1
    std::cout << "Language mode = gnu++11\n";
#else
    std::cout << "Language mode = c++11\n";
#endif
#else
#if __cplusplus == 1
    std::cout << "Language mode = gnu++98\n";
#else
    std::cout << "Language mode = c++98\n";
#endif
#endif
}

只需使用编译器认值构建一个测试项目并运行它.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐