Fix error suppression macro

My previous fix triggered another issue: apparently at least GCC expects
the `_Pragma` operator to be placed in its own statement (after a
semicolon). The current macro simply dumped the expression and the
_Pragma together, triggering an error. Putting a semicolon after `Expr`
fixes the issue (actually double-checked after a `git clean -fdx`),
although slightly changing the API (the semicolon after the wrapped
macros is now optional).
This commit is contained in:
Dery Almas
2025-11-15 21:38:08 +01:00
parent 36d3f1e0ab
commit e1110d6c58

View File

@@ -155,19 +155,19 @@
#define SuppressVarShadowWarning(Expr) \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Wshadow\"") \
Expr \
Expr; \
_Pragma("clang diagnostic pop")
#elif defined(__GNUC__)
#define SuppressVarShadowWarning(Expr) \
_Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Wshadow\"") \
Expr \
Expr; \
_Pragma("GCC diagnostic pop")
#elif defined(_MSC_VER)
#define SuppressVarShadowWarning(Expr) \
_Pragma("warning(push)") \
_Pragma("warning(disable : 4456)") \
Expr \
Expr; \
_Pragma("warning(pop)")
#else
#define SuppressVarShadowWarning(Expr) Expr