config_info.cpp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. static unsigned int indent = 4;
  18. static unsigned int width = 40;
  19. using std::cout;
  20. using std::istream;
  21. void print_separator()
  22. {
  23. std::cout <<
  24. "\n\n*********************************************************************\n\n";
  25. }
  26. void print_macro(const char* name, const char* value)
  27. {
  28. // if name == value+1 then then macro is not defined,
  29. // in which case we don't print anything:
  30. if(0 != strcmp(name, value+1))
  31. {
  32. for(unsigned i = 0; i < indent; ++i) std::cout.put(' ');
  33. std::cout << std::setw(width);
  34. cout.setf(istream::left, istream::adjustfield);
  35. std::cout << name;
  36. if(value[1])
  37. {
  38. // macro has a value:
  39. std::cout << value << "\n";
  40. }
  41. else
  42. {
  43. // macro is defined but has no value:
  44. std::cout << " [no value]\n";
  45. }
  46. }
  47. }
  48. #define PRINT_MACRO(X) print_macro(#X, BOOST_PP_STRINGIZE(=X))
  49. void print_macros()
  50. {
  51. print_separator();
  52. PRINT_MACRO(__GCCXML__);
  53. PRINT_MACRO(__WAVE__);
  54. PRINT_MACRO(__MWERKS__);
  55. PRINT_MACRO(__EDG__);
  56. PRINT_MACRO(_MSC_VER);
  57. PRINT_MACRO(__clang__);
  58. PRINT_MACRO(__DMC__);
  59. PRINT_MACRO(__BORLANDC__);
  60. PRINT_MACRO(__IBMC__);
  61. PRINT_MACRO(__IBMCPP__);
  62. PRINT_MACRO(__SUNPRO_CC);
  63. PRINT_MACRO(__CUDACC__);
  64. PRINT_MACRO(__PATHSCALE__);
  65. PRINT_MACRO(__CODEGEARC__);
  66. PRINT_MACRO(__HP_aCC);
  67. PRINT_MACRO(__SC__);
  68. PRINT_MACRO(__MRC__);
  69. PRINT_MACRO(__PGI);
  70. PRINT_MACRO(__INTEL_COMPILER);
  71. PRINT_MACRO(__GNUC__);
  72. PRINT_MACRO(__GXX_EXPERIMENTAL_CXX0X__);
  73. print_separator();
  74. PRINT_MACRO(__cplusplus);
  75. PRINT_MACRO(__STDC_VERSION__);
  76. PRINT_MACRO(__EDG_VERSION__);
  77. PRINT_MACRO(__INTELLISENSE__);
  78. PRINT_MACRO(__WAVE_HAS_VARIADICS__);
  79. print_separator();
  80. PRINT_MACRO(BOOST_PP_CONFIG_ERRORS);
  81. PRINT_MACRO(BOOST_PP_CONFIG_EXTENDED_LINE_INFO);
  82. PRINT_MACRO(BOOST_PP_CONFIG_FLAGS());
  83. PRINT_MACRO(BOOST_PP_VARIADICS);
  84. PRINT_MACRO(BOOST_PP_VARIADICS_MSVC);
  85. PRINT_MACRO(BOOST_PP_VARIADIC_HAS_OPT());
  86. }
  87. int main()
  88. {
  89. print_macros();
  90. return 0;
  91. }