Skip to content

Commit

Permalink
Instruct msvc to report the _true_ value in __cplusplus and force _…
Browse files Browse the repository at this point in the history
…full_ C++ conformance

 * do this  in _some_ tests to improve test coverage and catch possible problems due to that
 * fix invalid export of `static constexpr` constant
 * silence msvc warnings about unreachable code in high warning levels
  • Loading branch information
DanielaE committed Jun 13, 2021
1 parent f28cf33 commit f73b909
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions include/fmt/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@

#ifndef FMT_MODULE_EXPORT
# define FMT_MODULE_EXPORT
# define FMT_MODULE_EXPORT_CONSTANT static
# define FMT_MODULE_EXPORT_BEGIN
# define FMT_MODULE_EXPORT_END
# define FMT_BEGIN_DETAIL_NAMESPACE namespace detail {
Expand Down
2 changes: 1 addition & 1 deletion include/fmt/os.h
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ struct ostream_params {

FMT_END_DETAIL_NAMESPACE

static constexpr detail::buffer_size buffer_size;
FMT_MODULE_EXPORT_CONSTANT constexpr detail::buffer_size buffer_size;

/** A fast output stream which is not thread-safe. */
class FMT_API ostream final : private detail::buffer<char> {
Expand Down
4 changes: 4 additions & 0 deletions src/fmt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ module;
#ifndef __cpp_modules
# error Module not supported.
#endif
#ifdef _MSC_VER
# pragma warning(disable : 4702)
#endif

// put all implementation-provided headers into the global module fragment
// to prevent attachment to this module
Expand Down Expand Up @@ -71,6 +74,7 @@ module;
export module fmt;

#define FMT_MODULE_EXPORT export
#define FMT_MODULE_EXPORT_CONSTANT
#define FMT_MODULE_EXPORT_BEGIN export {
#define FMT_MODULE_EXPORT_END }
#define FMT_BEGIN_DETAIL_NAMESPACE \
Expand Down
6 changes: 4 additions & 2 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,10 @@ if (FMT_CAN_MODULE)

add_fmt_test(module-test MODULE)
if (MSVC)
target_compile_options(test-module PRIVATE /utf-8)
target_compile_options(module-test PRIVATE /utf-8)
target_compile_options(test-module PRIVATE /utf-8 /Zc:__cplusplus
/Zc:externConstexpr /Zc:inline)
target_compile_options(module-test PRIVATE /utf-8 /Zc:__cplusplus
/Zc:externConstexpr /Zc:inline)
endif ()
endif ()

Expand Down

0 comments on commit f73b909

Please sign in to comment.