In Xcode 4.5, what is “Compiler Default” for “C++ Standard Library” and “C++ Language Dialect”?

大城市里の小女人 提交于 2019-11-29 05:38:15

问题


What is the value of "Compiler Default" for "C++ Standard Library" and "C++ Language Dialect" in Xcode 4.5?

My guess is libstdc++ and GNU++98, but it would be nice to have clarification.

From the 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).

I notice that creating a new project explicitly sets GNU++11 and libc++, but "Compiler Default" is probably something else.


回答1:


Here is the best way to find out:

 #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
}

Just build a test project with the compiler defaults and run it.



来源:https://stackoverflow.com/questions/12865226/in-xcode-4-5-what-is-compiler-default-for-c-standard-library-and-c-lan

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!