如何通过宏检查是否使用了(GNU GCC)libstdc ++ STL实现?那可能吗?我想在GCC和Clang都有这个工作.
对于Linux上的C++ 11,它可能是唯一的选择(或者是它?).(STLport没有C++ 11支持,AFAIK.)在MacOSX上,(LLVM)libc ++ STL更有可能,如果你使用Clang(也许也适用于GCC,不确定).
您可以检查__GLIBCXX__
(或者__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/abi.html
https://gcc.gnu.org/onlinedocs/gcc-4.9.1/cpp/If.html