From f9f07704d28f85a27aca9a29cfa47926cfe8becf Mon Sep 17 00:00:00 2001 From: Vito <5780819+Tapanito@users.noreply.github.com> Date: Tue, 2 Jun 2026 12:58:00 +0200 Subject: [PATCH] refactor: Simplify XRPL_ASSERT_IF to fixed 3-parameter form The __VA_ARGS__ approach required an MSVC-specific EXPAND workaround. Switch back to explicit (guard, cond, message) parameters and document the bare-comma restriction on cond instead. --- include/xrpl/beast/utility/instrumentation.h | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/include/xrpl/beast/utility/instrumentation.h b/include/xrpl/beast/utility/instrumentation.h index afc36e7842..7326e8d60e 100644 --- a/include/xrpl/beast/utility/instrumentation.h +++ b/include/xrpl/beast/utility/instrumentation.h @@ -22,14 +22,12 @@ #define XRPL_ASSERT_PARTS(cond, function, description, ...) \ XRPL_ASSERT(cond, function " : " description) // clang-format off -// MSVC's legacy preprocessor treats __VA_ARGS__ as a single token when -// forwarded to another function-like macro. XRPL_ASSERT_IF_EXPAND forces a -// rescan that splits the tokens back into separate arguments. -#define XRPL_ASSERT_IF_EXPAND(x) x -#define XRPL_ASSERT_IF(guard, ...) \ - do { \ - if ((guard)) \ - XRPL_ASSERT_IF_EXPAND(XRPL_ASSERT(__VA_ARGS__)); \ +// NOTE: cond must not contain bare commas outside () or []. Commas inside {} +// are not protected by the preprocessor and would be parsed as extra arguments. +#define XRPL_ASSERT_IF(guard, cond, message) \ + do { \ + if ((guard)) \ + XRPL_ASSERT(cond, message); \ } while (false) // clang-format on