From d561cb47a76ea0563721809dfbd4f717741f21ca 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 632b7dfe..de398d29 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -1258,7 +1258,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);