[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: master 37889523278: Add new `swap` macro and use it
|
From: |
Andreas Schwab |
|
Subject: |
Re: master 37889523278: Add new `swap` macro and use it |
|
Date: |
Sat, 06 Jan 2024 10:52:58 +0100 |
|
User-agent: |
Gnus/5.13 (Gnus v5.13) |
On Jan 06 2024, Stefan Kangas wrote:
> diff --git a/src/lisp.h b/src/lisp.h
> index f96932ab0c1..a9782868157 100644
> --- a/src/lisp.h
> +++ b/src/lisp.h
> @@ -68,8 +68,13 @@ #define max(a, b) ((a) > (b) ? (a) : (b))
> #define min(a, b) ((a) < (b) ? (a) : (b))
>
> /* Swap values of a and b. */
> -#define swap(a, b) \
> - do { typeof (a) __tmp; __tmp = (a); (a) = (b); (b) = __tmp; } while (0);
> +#if _GL_HAVE___TYPEOF__
> +#define swap(type, a, b)
> \
> + do { __typeof__ (a) __tmp; __tmp = (a); (a) = (b); (b) = __tmp; } while
> (0);
> +#else
> +#define swap(type, a, b)
> \
> + do { type __tmp; __tmp = (a); (a) = (b); (b) = __tmp; } while (0);
> +#endif
Neither of these definitions are future proof: __tmp as a reserved
identifier might clash with future implementations. Moreover, the first
argument can easily become out of date without notice.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
"And now for something completely different."
Re: master 37889523278: Add new `swap` macro and use it, Stefan Kangas, 2024/01/13
Re: master 37889523278: Add new `swap` macro and use it, Stefan Kangas, 2024/01/06