如何通过宏检查是否使用了 (GNU GCC) libstdc++ STL 实现?那可能吗?我希望它能在 GCC 和 Clang 中工作。
对于 Linux 上的 C++11,它可能是唯一的选择(或者是吗?)。 (据我所知,STLport 不支持 C++11。)在 MacOSX 上,如果您使用 Clang(也许也适用于 GCC,不确定),则 (LLVM) libc++ STL 更有可能。
您可以检查__GLIBCXX__
(or __GLIBCPP__
,对于 3.4.0 之前的版本)宏存在,在包含 C++ 标准包含文件之一之后(cstddef
是一个不错的选择):
#include <cstddef>
#if defined(__GLIBCXX__) || defined(__GLIBCPP__)
/* Using GNU GCC libstdc++, so using also its STL implementation */
#endif
在这里阅读更多内容:
- https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_macros.html https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_macros.html
- https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html
- https://gcc.gnu.org/onlinedocs/gcc-4.9.1/cpp/If.html https://gcc.gnu.org/onlinedocs/gcc-4.9.1/cpp/If.html
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)