config.hpp 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. //
  2. // Copyright (c) 2012 Artyom Beilis (Tonkikh)
  3. // Copyright (c) 2019 - 2022 Alexander Grund
  4. //
  5. // Distributed under the Boost Software License, Version 1.0.
  6. // https://www.boost.org/LICENSE_1_0.txt
  7. #ifndef BOOST_NOWIDE_CONFIG_HPP_INCLUDED
  8. #define BOOST_NOWIDE_CONFIG_HPP_INCLUDED
  9. /// @file
  10. #include <boost/config.hpp>
  11. #include <boost/nowide/replacement.hpp>
  12. #include <boost/version.hpp>
  13. //! @cond Doxygen_Suppress
  14. #if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_NOWIDE_DYN_LINK)
  15. #ifdef BOOST_NOWIDE_SOURCE
  16. #define BOOST_NOWIDE_DECL BOOST_SYMBOL_EXPORT
  17. #else
  18. #define BOOST_NOWIDE_DECL BOOST_SYMBOL_IMPORT
  19. #endif // BOOST_NOWIDE_SOURCE
  20. #else
  21. #define BOOST_NOWIDE_DECL
  22. #endif // BOOST_NOWIDE_DYN_LINK
  23. // Automatically link to the correct build variant where possible.
  24. #if !defined(BOOST_ALL_NO_LIB) && !defined(BOOST_NOWIDE_NO_LIB) && !defined(BOOST_NOWIDE_SOURCE)
  25. //
  26. // Set the name of our library, this will get undef'ed by auto_link.hpp
  27. // once it's done with it:
  28. //
  29. #define BOOST_LIB_NAME boost_nowide
  30. //
  31. // If we're importing code from a dll, then tell auto_link.hpp about it:
  32. //
  33. #if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_NOWIDE_DYN_LINK)
  34. #define BOOST_DYN_LINK
  35. #endif
  36. //
  37. // And include the header that does the work:
  38. //
  39. #include <boost/config/auto_link.hpp>
  40. #endif // auto-linking disabled
  41. //! @endcond
  42. /// @def BOOST_NOWIDE_USE_WCHAR_OVERLOADS
  43. /// @brief Whether to use the wchar_t* overloads in fstream-classes.
  44. ///
  45. /// Enabled by default on Windows and Cygwin as the latter may use wchar_t in filesystem::path.
  46. #ifndef BOOST_NOWIDE_USE_WCHAR_OVERLOADS
  47. #if defined(BOOST_WINDOWS) || defined(__CYGWIN__) || defined(BOOST_NOWIDE_DOXYGEN)
  48. #define BOOST_NOWIDE_USE_WCHAR_OVERLOADS 1
  49. #else
  50. #define BOOST_NOWIDE_USE_WCHAR_OVERLOADS 0
  51. #endif
  52. #endif
  53. /// @def BOOST_NOWIDE_USE_FILEBUF_REPLACEMENT
  54. /// @brief Define to 1 to use the class from <filebuf.hpp> that is used on Windows.
  55. ///
  56. /// - On Windows: No effect, always overwritten to 1
  57. /// - Others (including Cygwin): Defaults to the value of #BOOST_NOWIDE_USE_WCHAR_OVERLOADS if not set.
  58. ///
  59. /// When set to 0 boost::nowide::basic_filebuf will be an alias for std::basic_filebuf.
  60. ///
  61. /// Affects boost::nowide::basic_filebuf,
  62. /// boost::nowide::basic_ofstream, boost::nowide::basic_ifstream, boost::nowide::basic_fstream
  63. #if defined(BOOST_WINDOWS) || defined(BOOST_NOWIDE_DOXYGEN)
  64. #ifdef BOOST_NOWIDE_USE_FILEBUF_REPLACEMENT
  65. #undef BOOST_NOWIDE_USE_FILEBUF_REPLACEMENT
  66. #endif
  67. #define BOOST_NOWIDE_USE_FILEBUF_REPLACEMENT 1
  68. #elif !defined(BOOST_NOWIDE_USE_FILEBUF_REPLACEMENT)
  69. #define BOOST_NOWIDE_USE_FILEBUF_REPLACEMENT BOOST_NOWIDE_USE_WCHAR_OVERLOADS
  70. #endif
  71. //! @cond Doxygen_Suppress
  72. #if BOOST_VERSION < 106500 && defined(__GNUC__) && __GNUC__ >= 7
  73. #define BOOST_NOWIDE_FALLTHROUGH __attribute__((fallthrough))
  74. #else
  75. #define BOOST_NOWIDE_FALLTHROUGH BOOST_FALLTHROUGH
  76. #endif
  77. // The std::codecvt<char16/32_t, char, std::mbstate_t> are deprecated in C++20
  78. // These macros can suppress this warning
  79. #if defined(_MSC_VER)
  80. #define BOOST_NOWIDE_SUPPRESS_UTF_CODECVT_DEPRECATION_BEGIN __pragma(warning(push)) __pragma(warning(disable : 4996))
  81. #define BOOST_NOWIDE_SUPPRESS_UTF_CODECVT_DEPRECATION_END __pragma(warning(pop))
  82. #elif(__cplusplus >= 202002L) && defined(__clang__)
  83. #define BOOST_NOWIDE_SUPPRESS_UTF_CODECVT_DEPRECATION_BEGIN \
  84. _Pragma("clang diagnostic push") _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
  85. #define BOOST_NOWIDE_SUPPRESS_UTF_CODECVT_DEPRECATION_END _Pragma("clang diagnostic pop")
  86. #elif(__cplusplus >= 202002L) && defined(__GNUC__)
  87. #define BOOST_NOWIDE_SUPPRESS_UTF_CODECVT_DEPRECATION_BEGIN \
  88. _Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
  89. #define BOOST_NOWIDE_SUPPRESS_UTF_CODECVT_DEPRECATION_END _Pragma("GCC diagnostic pop")
  90. #else
  91. #define BOOST_NOWIDE_SUPPRESS_UTF_CODECVT_DEPRECATION_BEGIN
  92. #define BOOST_NOWIDE_SUPPRESS_UTF_CODECVT_DEPRECATION_END
  93. #endif
  94. //! @endcond
  95. namespace boost {
  96. ///
  97. /// \brief This namespace includes implementations of the standard library functions and
  98. /// classes such that they accept UTF-8 strings on Windows.
  99. /// On other platforms (i.e. not on Windows) those functions and classes are just aliases
  100. /// of the corresponding ones from the std namespace or behave like them.
  101. ///
  102. namespace nowide {}
  103. } // namespace boost
  104. #endif