Portability.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. #ifndef CPPUNIT_PORTABILITY_H
  2. #define CPPUNIT_PORTABILITY_H
  3. #if defined(_WIN32) && !defined(WIN32)
  4. # define WIN32 1
  5. #endif
  6. /* include platform specific config */
  7. #if defined(__BORLANDC__)
  8. # include <cppunit/config/config-bcb5.h>
  9. #elif defined (_MSC_VER)
  10. # if _MSC_VER == 1200 && defined(_WIN32_WCE) //evc4
  11. # include <cppunit/config/config-evc4.h>
  12. # else
  13. # include <cppunit/config/config-msvc6.h>
  14. # endif
  15. #else
  16. # include <cppunit/config-auto.h>
  17. #endif
  18. // Version number of package
  19. #ifndef CPPUNIT_VERSION
  20. #define CPPUNIT_VERSION "1.12.0"
  21. #endif
  22. #include <cppunit/config/CppUnitApi.h> // define CPPUNIT_API & CPPUNIT_NEED_DLL_DECL
  23. #include <cppunit/config/SelectDllLoader.h>
  24. /* Options that the library user may switch on or off.
  25. * If the user has not done so, we chose default values.
  26. */
  27. /* Define to 1 if you wish to have the old-style macros
  28. assert(), assertEqual(), assertDoublesEqual(), and assertLongsEqual() */
  29. #if !defined(CPPUNIT_ENABLE_NAKED_ASSERT)
  30. # define CPPUNIT_ENABLE_NAKED_ASSERT 0
  31. #endif
  32. /* Define to 1 if you wish to have the old-style CU_TEST family
  33. of macros. */
  34. #if !defined(CPPUNIT_ENABLE_CU_TEST_MACROS)
  35. # define CPPUNIT_ENABLE_CU_TEST_MACROS 0
  36. #endif
  37. /* Define to 1 if the preprocessor expands (#foo) to "foo" (quotes incl.)
  38. I don't think there is any C preprocess that does NOT support this! */
  39. #if !defined(CPPUNIT_HAVE_CPP_SOURCE_ANNOTATION)
  40. # define CPPUNIT_HAVE_CPP_SOURCE_ANNOTATION 1
  41. #endif
  42. /* Assumes that STL and CppUnit are in global space if the compiler does not
  43. support namespace. */
  44. #if !defined(CPPUNIT_HAVE_NAMESPACES)
  45. # if !defined(CPPUNIT_NO_NAMESPACE)
  46. # define CPPUNIT_NO_NAMESPACE 1
  47. # endif // !defined(CPPUNIT_NO_NAMESPACE)
  48. # if !defined(CPPUNIT_NO_STD_NAMESPACE)
  49. # define CPPUNIT_NO_STD_NAMESPACE 1
  50. # endif // !defined(CPPUNIT_NO_STD_NAMESPACE)
  51. #endif // !defined(CPPUNIT_HAVE_NAMESPACES)
  52. /* Define CPPUNIT_STD_NEED_ALLOCATOR to 1 if you need to specify
  53. * the allocator you used when instantiating STL container. Typically
  54. * used for compilers that do not support template default parameter.
  55. * CPPUNIT_STD_ALLOCATOR will be used as the allocator. Default is
  56. * std::allocator. On some compilers, you may need to change this to
  57. * std::allocator<T>.
  58. */
  59. #if CPPUNIT_STD_NEED_ALLOCATOR
  60. # if !defined(CPPUNIT_STD_ALLOCATOR)
  61. # define CPPUNIT_STD_ALLOCATOR std::allocator
  62. # endif // !defined(CPPUNIT_STD_ALLOCATOR)
  63. #endif // defined(CPPUNIT_STD_NEED_ALLOCATOR)
  64. // Compiler error location format for CompilerOutputter
  65. // If not define, assumes that it's gcc
  66. // See class CompilerOutputter for format.
  67. #if !defined(CPPUNIT_COMPILER_LOCATION_FORMAT)
  68. #if defined(__GNUC__) && ( defined(__APPLE_CPP__) || defined(__APPLE_CC__) )
  69. // gcc/Xcode integration on Mac OS X
  70. # define CPPUNIT_COMPILER_LOCATION_FORMAT "%p:%l: "
  71. #else
  72. # define CPPUNIT_COMPILER_LOCATION_FORMAT "%f:%l:"
  73. #endif
  74. #endif
  75. // If CPPUNIT_HAVE_CPP_CAST is defined, then c++ style cast will be used,
  76. // otherwise, C style cast are used.
  77. #if defined( CPPUNIT_HAVE_CPP_CAST )
  78. # define CPPUNIT_CONST_CAST( TargetType, pointer ) \
  79. const_cast<TargetType>( pointer )
  80. # define CPPUNIT_STATIC_CAST( TargetType, pointer ) \
  81. static_cast<TargetType>( pointer )
  82. #else // defined( CPPUNIT_HAVE_CPP_CAST )
  83. # define CPPUNIT_CONST_CAST( TargetType, pointer ) \
  84. ((TargetType)( pointer ))
  85. # define CPPUNIT_STATIC_CAST( TargetType, pointer ) \
  86. ((TargetType)( pointer ))
  87. #endif // defined( CPPUNIT_HAVE_CPP_CAST )
  88. // If CPPUNIT_NO_STD_NAMESPACE is defined then STL are in the global space.
  89. // => Define macro 'std' to nothing
  90. #if defined(CPPUNIT_NO_STD_NAMESPACE)
  91. # undef std
  92. # define std
  93. #endif // defined(CPPUNIT_NO_STD_NAMESPACE)
  94. // If CPPUNIT_NO_NAMESPACE is defined, then put CppUnit classes in the
  95. // global namespace: the compiler does not support namespace.
  96. #if defined(CPPUNIT_NO_NAMESPACE)
  97. # define CPPUNIT_NS_BEGIN
  98. # define CPPUNIT_NS_END
  99. # define CPPUNIT_NS
  100. #else // defined(CPPUNIT_NO_NAMESPACE)
  101. # define CPPUNIT_NS_BEGIN namespace CppUnit {
  102. # define CPPUNIT_NS_END }
  103. # define CPPUNIT_NS CppUnit
  104. #endif // defined(CPPUNIT_NO_NAMESPACE)
  105. /*! Stringize a symbol.
  106. *
  107. * Use this macro to convert a preprocessor symbol to a string.
  108. *
  109. * Example of usage:
  110. * \code
  111. * #define CPPUNIT_PLUGIN_EXPORTED_NAME cppunitTestPlugIn
  112. * const char *name = CPPUNIT_STRINGIZE( CPPUNIT_PLUGIN_EXPORTED_NAME );
  113. * \endcode
  114. */
  115. #define CPPUNIT_STRINGIZE( symbol ) _CPPUNIT_DO_STRINGIZE( symbol )
  116. /// \internal
  117. #define _CPPUNIT_DO_STRINGIZE( symbol ) #symbol
  118. /*! Joins to symbol after expanding them into string.
  119. *
  120. * Use this macro to join two symbols. Example of usage:
  121. *
  122. * \code
  123. * #define MAKE_UNIQUE_NAME(prefix) CPPUNIT_JOIN( prefix, __LINE__ )
  124. * \endcode
  125. *
  126. * The macro defined in the example concatenate a given prefix with the line number
  127. * to obtain a 'unique' identifier.
  128. *
  129. * \internal From boost documentation:
  130. * The following piece of macro magic joins the two
  131. * arguments together, even when one of the arguments is
  132. * itself a macro (see 16.3.1 in C++ standard). The key
  133. * is that macro expansion of macro arguments does not
  134. * occur in CPPUNIT_JOIN2 but does in CPPUNIT_JOIN.
  135. */
  136. #define CPPUNIT_JOIN( symbol1, symbol2 ) _CPPUNIT_DO_JOIN( symbol1, symbol2 )
  137. /// \internal
  138. #define _CPPUNIT_DO_JOIN( symbol1, symbol2 ) _CPPUNIT_DO_JOIN2( symbol1, symbol2 )
  139. /// \internal
  140. #define _CPPUNIT_DO_JOIN2( symbol1, symbol2 ) symbol1##symbol2
  141. /*! Adds the line number to the specified string to create a unique identifier.
  142. * \param prefix Prefix added to the line number to create a unique identifier.
  143. * \see CPPUNIT_TEST_SUITE_REGISTRATION for an example of usage.
  144. */
  145. #define CPPUNIT_MAKE_UNIQUE_NAME( prefix ) CPPUNIT_JOIN( prefix, __LINE__ )
  146. /*! Defines wrap colunm for %CppUnit. Used by CompilerOuputter.
  147. */
  148. #if !defined(CPPUNIT_WRAP_COLUMN)
  149. # define CPPUNIT_WRAP_COLUMN 79
  150. #endif
  151. #endif // CPPUNIT_PORTABILITY_H