aboutsummaryrefslogtreecommitdiff
path: root/stdlib/util.h
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-11-12 00:04:56 -0500
committerBruce Hill <bruce@bruce-hill.com>2024-11-12 00:04:56 -0500
commita4d11f51ff409901e92a35983ace8b9b2a7ec2d3 (patch)
tree0b2bc4faab88e49b2d9a0f6350280700e359084e /stdlib/util.h
parent5b8f7179ad28e615d1cc40753125f4f296dd5b59 (diff)
Fixes for 'if' blocks with nested 'else if' that declare variables
Diffstat (limited to 'stdlib/util.h')
-rw-r--r--stdlib/util.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/stdlib/util.h b/stdlib/util.h
index fb708476..310ba905 100644
--- a/stdlib/util.h
+++ b/stdlib/util.h
@@ -17,6 +17,8 @@
#define check_initialized(var, name) *({ if (!var ## $initialized) fail("The variable " name " is being accessed before it has been initialized!"); \
&var; })
+#define IF_DECLARE(decl, expr, block) if (({ decl; expr ? ({ block; 1; }) : 0; })) {}
+
#ifndef auto
#define auto __auto_type
#endif