Skip to content

Commit

Permalink
MSVC named module fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
MathiasMagnus committed Dec 27, 2023
1 parent cb4800e commit d1d683e
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions include/boost/ut.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// http://www.boost.org/LICENSE_1_0.txt)
//
#if defined(__cpp_modules) && !defined(BOOST_UT_DISABLE_MODULE)
#define BOOST_UT_MODULE_MODE
export module boost.ut;
export import std;
#define BOOST_UT_EXPORT export
Expand All @@ -14,6 +15,7 @@ export import std;
#define BOOST_UT_EXPORT
#endif

#if !defined(BOOST_UT_MODULE_MODE) && !defined(_MSC_VER)
#if __has_include(<iso646.h>)
#include <iso646.h> // and, or, not, ...
#endif
Expand All @@ -25,6 +27,7 @@ export import std;
#undef min
#undef max
#endif
#endif
// Before libc++ 17 had experimental support for format and it required a
// special build flag. Currently libc++ has not implemented all C++20 chrono
// improvements. Therefore doesn't define __cpp_lib_format, instead query the
Expand Down Expand Up @@ -72,6 +75,7 @@ export import std;
#define __has_builtin(...) __has_##__VA_ARGS__
#endif

#if !defined(BOOST_UT_MODULE_MODE) && !defined(_MSC_VER)
#include <algorithm>
#include <array>
#include <chrono>
Expand All @@ -97,13 +101,20 @@ export import std;
#if defined(__cpp_exceptions)
#include <exception>
#endif

#if __has_include(<format>)
#include <format>
#endif
#if __has_include(<source_location>)
#include <source_location>
#endif
#endif

#if defined(BOOST_UT_MODULE_MODE) && defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable : 5244) // '#include <stdlib.h>' in the purview of module 'boost.ut' appears erroneous.
#include <stdlib.h>
#pragma warning(pop)
#endif

struct _unique_name_for_auto_detect_prefix_and_suffix_lenght_0123456789_struct {
};
Expand Down Expand Up @@ -2749,13 +2760,17 @@ namespace terse {
#pragma clang diagnostic ignored "-Wunused-comparison"
#endif

// error C2294: cannot export symbol 'boost::ext::ut::vx_y_z::operators::terse::_t' because it has internal linkage
// error C2294: cannot export symbol 'boost::ext::ut::vx_y_z::operators::terse::operator %' because it has internal linkage
#if !(defined(BOOST_UT_MODULE_MODE) && defined(_MSC_VER))
[[maybe_unused]] constexpr struct {
} _t;

template <class T>
constexpr auto operator%(const T& t, const decltype(_t)&) {
return detail::value<T>{t};
}
#endif

template <class T>
inline auto operator>>(const T& t,
Expand Down Expand Up @@ -3289,7 +3304,7 @@ __attribute__((constructor)) inline void cmd_line_args(int argc,
// For MSVC, largc/largv are initialized with __argc/__argv
#endif

#if defined(_MSC_VER)
#if !defined(BOOST_UT_MODULE_MODE) && defined(_MSC_VER)
#pragma pop_macro("min")
#pragma pop_macro("max")
#endif
Expand Down

0 comments on commit d1d683e

Please sign in to comment.