Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MSVC named module enablement #604

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading