1# /* **************************************************************************
2# * *
3# * (C) Copyright Edward Diener 2014,2019.
4# * Distributed under the Boost Software License, Version 1.0. (See
5# * accompanying file LICENSE_1_0.txt or copy at
6# * http://www.boost.org/LICENSE_1_0.txt)
7# * *
8# ************************************************************************** */
9#
10# /* See http://www.boost.org for most recent version. */
11#
12#include <iostream>
13#include <iomanip>
14#include <string.h>
15#include <boost/preprocessor/stringize.hpp>
16#include <boost/preprocessor/variadic/has_opt.hpp>
17
18static unsigned int indent = 4;
19static unsigned int width = 40;
20
21using std::cout;
22using std::istream;
23
24void print_separator()
25{
26 std::cout <<
27"\n\n*********************************************************************\n\n";
28}
29
30void print_macro(const char* name, const char* value)
31{
32 // if name == value+1 then then macro is not defined,
33 // in which case we don't print anything:
34 if(0 != strcmp(s1: name, s2: value+1))
35 {
36 for(unsigned i = 0; i < indent; ++i) std::cout.put(c: ' ');
37 std::cout << std::setw(width);
38 cout.setf(fmtfl: istream::left, mask: istream::adjustfield);
39 std::cout << name;
40 if(value[1])
41 {
42 // macro has a value:
43 std::cout << value << "\n";
44 }
45 else
46 {
47 // macro is defined but has no value:
48 std::cout << " [no value]\n";
49 }
50 }
51}
52
53#define PRINT_MACRO(X) print_macro(#X, BOOST_PP_STRINGIZE(=X))
54
55void print_macros()
56{
57
58 print_separator();
59
60 PRINT_MACRO(__GCCXML__);
61 PRINT_MACRO(__WAVE__);
62 PRINT_MACRO(__MWERKS__);
63 PRINT_MACRO(__EDG__);
64 PRINT_MACRO(_MSC_VER);
65 PRINT_MACRO(__clang__);
66 PRINT_MACRO(__DMC__);
67 PRINT_MACRO(__BORLANDC__);
68 PRINT_MACRO(__IBMC__);
69 PRINT_MACRO(__IBMCPP__);
70 PRINT_MACRO(__SUNPRO_CC);
71 PRINT_MACRO(__CUDACC__);
72 PRINT_MACRO(__PATHSCALE__);
73 PRINT_MACRO(__CODEGEARC__);
74 PRINT_MACRO(__HP_aCC);
75 PRINT_MACRO(__SC__);
76 PRINT_MACRO(__MRC__);
77 PRINT_MACRO(__PGI);
78 PRINT_MACRO(__INTEL_COMPILER);
79 PRINT_MACRO(__GNUC__);
80 PRINT_MACRO(__GXX_EXPERIMENTAL_CXX0X__);
81
82 print_separator();
83
84 PRINT_MACRO(__cplusplus);
85 PRINT_MACRO(__STDC_VERSION__);
86 PRINT_MACRO(__EDG_VERSION__);
87 PRINT_MACRO(__INTELLISENSE__);
88 PRINT_MACRO(__WAVE_HAS_VARIADICS__);
89
90 print_separator();
91
92 PRINT_MACRO(BOOST_PP_CONFIG_ERRORS);
93 PRINT_MACRO(BOOST_PP_CONFIG_EXTENDED_LINE_INFO);
94 PRINT_MACRO(BOOST_PP_CONFIG_FLAGS());
95 PRINT_MACRO(BOOST_PP_VARIADICS_MSVC);
96 PRINT_MACRO(BOOST_PP_VARIADIC_HAS_OPT());
97}
98
99int main()
100{
101
102 print_macros();
103
104 return 0;
105}
106

source code of boost/libs/preprocessor/test/config_info.cpp