-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Module linkage fixes for shared build #4169
Changes from 5 commits
e1789cf
27f9966
9ca41fa
a67e251
f9e99e5
afb5f21
8765197
076afe3
7226c0e
d6c7200
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1792,9 +1792,9 @@ template <typename T> class buffer { | |
}; | ||
|
||
struct buffer_traits { | ||
explicit buffer_traits(size_t) {} | ||
auto count() const -> size_t { return 0; } | ||
auto limit(size_t size) -> size_t { return size; } | ||
FMT_CONSTEXPR explicit buffer_traits(size_t) {} | ||
FMT_CONSTEXPR auto count() const -> size_t { return 0; } | ||
FMT_CONSTEXPR auto limit(size_t size) -> size_t { return size; } | ||
}; | ||
|
||
class fixed_buffer_traits { | ||
|
@@ -1803,9 +1803,9 @@ class fixed_buffer_traits { | |
size_t limit_; | ||
|
||
public: | ||
explicit fixed_buffer_traits(size_t limit) : limit_(limit) {} | ||
auto count() const -> size_t { return count_; } | ||
auto limit(size_t size) -> size_t { | ||
FMT_CONSTEXPR explicit fixed_buffer_traits(size_t limit) : limit_(limit) {} | ||
FMT_CONSTEXPR auto count() const -> size_t { return count_; } | ||
FMT_CONSTEXPR auto limit(size_t size) -> size_t { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here and in a few more places below. |
||
size_t n = limit_ > count_ ? limit_ - count_ : 0; | ||
count_ += size; | ||
return size < n ? size : n; | ||
|
@@ -2223,7 +2223,7 @@ struct locale_ref { | |
public: | ||
constexpr locale_ref() : locale_(nullptr) {} | ||
template <typename Locale> explicit locale_ref(const Locale& loc); | ||
explicit operator bool() const noexcept { return locale_ != nullptr; } | ||
FMT_INLINE explicit operator bool() const noexcept { return locale_ != nullptr; } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here and elsewhere, please use |
||
#endif | ||
|
||
template <typename Locale> auto get() const -> Locale; | ||
|
@@ -2598,7 +2598,7 @@ class context : private detail::locale_ref { | |
void operator=(const context&) = delete; | ||
|
||
FMT_CONSTEXPR auto arg(int id) const -> format_arg { return args_.get(id); } | ||
auto arg(string_view name) -> format_arg { return args_.get(name); } | ||
FMT_INLINE auto arg(string_view name) -> format_arg { return args_.get(name); } | ||
FMT_CONSTEXPR auto arg_id(string_view name) -> int { | ||
return args_.get_id(name); | ||
} | ||
|
@@ -2607,7 +2607,7 @@ class context : private detail::locale_ref { | |
FMT_CONSTEXPR auto out() -> iterator { return out_; } | ||
|
||
// Advances the begin iterator to `it`. | ||
void advance_to(iterator) {} | ||
FMT_CONSTEXPR void advance_to(iterator) {} | ||
|
||
FMT_CONSTEXPR auto locale() -> detail::locale_ref { return *this; } | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -540,24 +540,24 @@ inline auto localtime(std::time_t time) -> std::tm { | |
std::time_t time_; | ||
std::tm tm_; | ||
|
||
dispatcher(std::time_t t) : time_(t) {} | ||
FMT_INLINE dispatcher(std::time_t t) : time_(t) {} | ||
|
||
auto run() -> bool { | ||
FMT_INLINE auto run() -> bool { | ||
using namespace fmt::detail; | ||
return handle(localtime_r(&time_, &tm_)); | ||
} | ||
|
||
auto handle(std::tm* tm) -> bool { return tm != nullptr; } | ||
FMT_INLINE auto handle(std::tm* tm) -> bool { return tm != nullptr; } | ||
|
||
auto handle(detail::null<>) -> bool { | ||
FMT_INLINE auto handle(detail::null<>) -> bool { | ||
using namespace fmt::detail; | ||
return fallback(localtime_s(&tm_, &time_)); | ||
} | ||
|
||
auto fallback(int res) -> bool { return res == 0; } | ||
FMT_INLINE auto fallback(int res) -> bool { return res == 0; } | ||
|
||
#if !FMT_MSC_VERSION | ||
auto fallback(detail::null<>) -> bool { | ||
FMT_INLINE auto fallback(detail::null<>) -> bool { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not needed since the struct where these functions are defined is inaccessible to module consumers. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Although I may have branched out a little when making the changes, the vast majority of them were made on functions that were generating linker errors. I've verified again, these are necessary for the linker to succeed. Essentially, the issue being addressed here is one of dll symbol export, not module name export, and so the visibility of names (which is what module export/detail namespaces relate to) I think has no bearing. Since this struct is in an |
||
using namespace fmt::detail; | ||
std::tm* tm = std::localtime(&time_); | ||
if (tm) tm_ = *tm; | ||
|
@@ -591,24 +591,24 @@ inline auto gmtime(std::time_t time) -> std::tm { | |
std::time_t time_; | ||
std::tm tm_; | ||
|
||
dispatcher(std::time_t t) : time_(t) {} | ||
FMT_INLINE dispatcher(std::time_t t) : time_(t) {} | ||
|
||
auto run() -> bool { | ||
FMT_INLINE auto run() -> bool { | ||
using namespace fmt::detail; | ||
return handle(gmtime_r(&time_, &tm_)); | ||
} | ||
|
||
auto handle(std::tm* tm) -> bool { return tm != nullptr; } | ||
FMT_INLINE auto handle(std::tm* tm) -> bool { return tm != nullptr; } | ||
|
||
auto handle(detail::null<>) -> bool { | ||
FMT_INLINE auto handle(detail::null<>) -> bool { | ||
using namespace fmt::detail; | ||
return fallback(gmtime_s(&tm_, &time_)); | ||
} | ||
|
||
auto fallback(int res) -> bool { return res == 0; } | ||
FMT_INLINE auto fallback(int res) -> bool { return res == 0; } | ||
|
||
#if !FMT_MSC_VERSION | ||
auto fallback(detail::null<>) -> bool { | ||
FMT_INLINE auto fallback(detail::null<>) -> bool { | ||
vitaut marked this conversation as resolved.
Show resolved
Hide resolved
|
||
std::tm* tm = std::gmtime(&time_); | ||
if (tm) tm_ = *tm; | ||
return tm != nullptr; | ||
|
@@ -912,7 +912,7 @@ template <typename Derived> struct null_chrono_spec_handler { | |
}; | ||
|
||
struct tm_format_checker : null_chrono_spec_handler<tm_format_checker> { | ||
FMT_NORETURN void unsupported() { FMT_THROW(format_error("no format")); } | ||
FMT_NORETURN FMT_INLINE void unsupported() { FMT_THROW(format_error("no format")); } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here and in other places in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As above, |
||
|
||
template <typename Char> | ||
FMT_CONSTEXPR void on_text(const Char*, const Char*) {} | ||
|
@@ -1572,7 +1572,7 @@ class tm_writer { | |
struct chrono_format_checker : null_chrono_spec_handler<chrono_format_checker> { | ||
bool has_precision_integral = false; | ||
|
||
FMT_NORETURN void unsupported() { FMT_THROW(format_error("no date")); } | ||
FMT_NORETURN FMT_INLINE void unsupported() { FMT_THROW(format_error("no date")); } | ||
|
||
template <typename Char> | ||
FMT_CONSTEXPR void on_text(const Char*, const Char*) {} | ||
|
@@ -1693,14 +1693,14 @@ class get_locale { | |
bool has_locale_ = false; | ||
|
||
public: | ||
get_locale(bool localized, locale_ref loc) : has_locale_(localized) { | ||
FMT_INLINE get_locale(bool localized, locale_ref loc) : has_locale_(localized) { | ||
if (localized) | ||
::new (&locale_) std::locale(loc.template get<std::locale>()); | ||
} | ||
~get_locale() { | ||
FMT_INLINE ~get_locale() { | ||
if (has_locale_) locale_.~locale(); | ||
} | ||
operator const std::locale&() const { | ||
FMT_INLINE operator const std::locale&() const { | ||
return has_locale_ ? locale_ : get_classic_locale(); | ||
} | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These can be
constexpr
.FMT_CONSTEXPR
is only for cases when C++14 relaxedconstexpr
is needed.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay my bad, hadn't realized the distinction. I think all the changes are now
constexpr
where they can be.