summaryrefslogtreecommitdiffstats
path: root/lib.h
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2022-10-26 01:58:44 -0700
committerKaz Kylheku <kaz@kylheku.com>2022-10-26 01:58:44 -0700
commite35e627e24bb2336769245d33930c3e42fc89d51 (patch)
tree29e5f74d8c0db16eda7355fb4c01c503ff6d30b3 /lib.h
parentaf623d27b590f3596b219c9be2faa1853f8d9db4 (diff)
downloadtxr-e35e627e24bb2336769245d33930c3e42fc89d51.tar.gz
txr-e35e627e24bb2336769245d33930c3e42fc89d51.tar.bz2
txr-e35e627e24bb2336769245d33930c3e42fc89d51.zip
lib: or2: define in GCC-specific way.
* lib.h (or2): Define simply using the ?: operator from GNU C, eliminating the explicit temporary variable. (uses_or2): For GNU C, we make this a dummy, harmless declaration. If memory serves me, one of the few good ways to do that it without eliciting unused warnings is to declare an enum.
Diffstat (limited to 'lib.h')
-rw-r--r--lib.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib.h b/lib.h
index 34f00c09..a161133c 100644
--- a/lib.h
+++ b/lib.h
@@ -1442,9 +1442,13 @@ INLINE int null_or_missing_p(val v) { return (nilp(v) || missingp(v)); }
#define if3(a, b, c) ((a) ? (b) : (c))
+#ifdef __GNUC__
+#define uses_or2 enum { f_o_o_ ## __LINE__ }
+#define or2(a, b) ((a) ?: (b))
+#else
#define uses_or2 val or2_temp
-
#define or2(a, b) ((or2_temp = (a)) ? or2_temp : (b))
+#endif
#define or3(a, b, c) or2(a, or2(b, c))