From 24874ebc2d6332ea68cff638370bfd1083be4d82 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Sun, 14 Jul 2019 19:04:37 -1000 Subject: [PATCH] Opt-in macro to enforce use of compile-time format strings --- include/fmt/core.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index 08312f7c..d201a372 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -1256,7 +1256,13 @@ template struct named_arg : named_arg_base { }; template ::value)> -inline void check_format_string(const S&) {} +inline void check_format_string(const S&) { +#if defined(FMT_ENFORCE_COMPILE_STRING) + static_assert(is_compile_string::value, + "FMT_ENFORCE_COMPILE_STRING requires all format strings to " + "utilize FMT_STRING() or fmt()."); +#endif +} template ::value)> void check_format_string(S);