Skip to content

Commit cf74caa

Browse files
committed
Simplify warning suppression
1 parent 71c6379 commit cf74caa

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

include/fmt/base.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -223,11 +223,6 @@
223223
#else
224224
# define FMT_PRAGMA_CLANG(x)
225225
#endif
226-
#if FMT_MSC_VERSION
227-
# define FMT_MSC_WARNING(...) __pragma(warning(__VA_ARGS__))
228-
#else
229-
# define FMT_MSC_WARNING(...)
230-
#endif
231226

232227
// Enable minimal optimizations for more compact code in debug mode.
233228
FMT_PRAGMA_GCC(push_options)
@@ -1741,9 +1736,12 @@ template <typename T> class buffer {
17411736

17421737
protected:
17431738
// Don't initialize ptr_ since it is not accessed to save a few cycles.
1744-
FMT_MSC_WARNING(suppress : 26495)
17451739
constexpr buffer(grow_fun grow, size_t sz) noexcept
1746-
: size_(sz), capacity_(sz), grow_(grow) {}
1740+
: size_(sz), capacity_(sz), grow_(grow) {
1741+
#if FMT_MSC_VERSION
1742+
ptr_ = nullptr; // Suppress warning 26495.
1743+
#endif
1744+
}
17471745

17481746
constexpr buffer(grow_fun grow, T* p = nullptr, size_t sz = 0,
17491747
size_t cap = 0) noexcept

include/fmt/format.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,12 @@
156156
# define FMT_CONSTEXPR_STRING
157157
#endif
158158

159+
#if FMT_MSC_VERSION
160+
# define FMT_MSC_WARNING(...) __pragma(warning(__VA_ARGS__))
161+
#else
162+
# define FMT_MSC_WARNING(...)
163+
#endif
164+
159165
// GCC 4.9 doesn't support qualified names in specializations.
160166
namespace std {
161167
template <typename T> struct iterator_traits<fmt::basic_appender<T>> {

0 commit comments

Comments
 (0)