Skip to content

Commit

Permalink
[msvc] fix warning about non-inline variable
Browse files Browse the repository at this point in the history
  • Loading branch information
russelltg authored and vitaut committed Feb 11, 2023
1 parent 3c5464b commit 6e6eb63
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion include/fmt/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,12 @@
# endif
#endif

#if defined __cpp_inline_variables && __cpp_inline_variables >= 201606L
# define FMT_INLINE_VARIABLE inline
#else
# define FMT_INLINE_VARIABLE
#endif

// Enable minimal optimizations for more compact code in debug mode.
FMT_GCC_PRAGMA("GCC push_options")
#if !defined(__OPTIMIZE__) && !defined(__NVCOMPILER) && !defined(__LCC__)
Expand Down Expand Up @@ -2662,7 +2668,7 @@ FMT_CONSTEXPR auto check_char_specs(const format_specs<Char>& specs) -> bool {
return true;
}

constexpr int invalid_arg_index = -1;
constexpr FMT_INLINE_VARIABLE int invalid_arg_index = -1;

#if FMT_USE_NONTYPE_TEMPLATE_ARGS
template <int N, typename T, typename... Args, typename Char>
Expand Down
2 changes: 1 addition & 1 deletion include/fmt/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ FMT_CONSTEXPR inline auto utf8_decode(const char* s, uint32_t* c, int* e)
return next;
}

constexpr uint32_t invalid_code_point = ~uint32_t();
constexpr FMT_INLINE_VARIABLE uint32_t invalid_code_point = ~uint32_t();

// Invokes f(cp, sv) for every code point cp in s with sv being the string view
// corresponding to the code point. cp is invalid_code_point on error.
Expand Down

0 comments on commit 6e6eb63

Please sign in to comment.