From eb2afffe5cfdc6aff82b2571c3d25d06ee7c2f8f Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 26 Oct 2022 01:58:44 -0700 Subject: 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. --- lib.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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)) -- cgit v1.2.3