在Xcode 4.5中,“C标准库”和“C语言方言”的“编译器默认”是什么?
作者:互联网
Xcode 4.5中“C标准库”和“C语言方言”的“编译器默认值”有什么价值?
我的猜测是libstdc和GNU 98,但澄清一下会很好.
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. 12221787To 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
}
只需使用编译器默认值构建一个测试项目并运行它.
标签:c,c11,xcode,libc-2,libstdc 来源: https://codeday.me/bug/20190725/1537111.html