From f692244ce725a1f8b0c7c2c88c6f6a76e64d6ea9 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sat, 16 Mar 2024 22:31:58 +0100 Subject: [PATCH] Improve error message with unsupported cpp (#4272) * Improve error message with unsupported cpp * Update include/metaprogram.h Co-authored-by: Martin Griffin --------- Co-authored-by: Martin Griffin --- include/metaprogram.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/metaprogram.h b/include/metaprogram.h index eee79b73b1..4bcc306b6f 100644 --- a/include/metaprogram.h +++ b/include/metaprogram.h @@ -2,6 +2,15 @@ #ifndef METAPROGRAM_H #define METAPROGRAM_H +/* Check if VA_OPT_ is supported by the compiler. GCC's version should be at least 9.5*/ +#define PP_THIRD_ARG(a,b,c,...) c +#define VA_OPT_SUPPORTED_I(...) PP_THIRD_ARG(__VA_OPT__(,),TRUE,FALSE,) +#define VA_OPT_SUPPORTED VA_OPT_SUPPORTED_I(?) + +#if !VA_OPT_SUPPORTED +#error ERROR: VA_OPT__ is not supported. Please update your gcc compiler to version 10 or higher +#endif // VA_OPT_SUPPORTED + /* Calls m0/m1/.../m8 depending on how many arguments are passed. */ #define VARARG_8(m, ...) CAT(m, NARG_8(__VA_ARGS__))(__VA_ARGS__)