#include <iostream>
#include <vector>
using namespace std;
int main()
{
# if defined(__sgi)
cout << "__sig" << endl;
# endif
# if defined(__GNUC__)
cout << "_GNUC_" << endl;
cout << _GNUC_ << ' ' << _GNUC_MINOR_ << endl;
# endif
# ifdef __STL_NO_DRAND48
cout << "__STL_NO_DRAND48 defined" << endl;
# else
cout << "__STL_NO_DRAND48 undefined" << endl;
# endif
# ifdef __STL_STATIC_TEMPLATE_MEMBER_BUG
cout << "__STL_STATIC_TEMPLATE_MEMBER_BUG defined" << endl;
# else
cout << "__STL_STATIC_TEMPLATE_MEMBER_BUG undefined" << endl;
# endif
# ifdef __STL_WIN32THREADS
cout << "__STL_WIN32THREADS defined" << endl;
# else
cout << "__STL_WIN32THREADSk undefined" << endl;
# endif
# ifdef __STL_ASSERTIONS
cout << "__STL_ASSERTIONS defined" << endl;
# else
cout << "__STL_ASSERTIONS undefined" << endl;
# endif
# ifdef __STL_NEED_BOOL
cout << "__STL_NEED_BOOL defined" << endl;
# else
cout << "__STL_NEED_BOOL undefined" << endl;
# endif
system("pause");
}
本文通过一个C++程序示例介绍了如何使用预处理器指令来检测编译器特性和标准库配置。其中包括了对特定编译器(__sgi, __GNUC__)的检测,以及对标准库特性(__STL_NO_DRAND48等)的判断。
1795

被折叠的 条评论
为什么被折叠?



