RE: [PATCH v2 next] compiler.h: Move __is_constexpr() to compiler.h.

From: David Laight
Date: Fri Oct 06 2023 - 11:51:17 EST


It can also be defined more portably as:

#define __is_constexpr(x) \
_Generic(0 ? (void *)((long)(x) * 0) : (int *)0, int *: 1, void *: 0)

Which doesn't rely on 'sizeof (void)' being valid.

But that is for another day.

There is also:
#define is_pointer_type(type) __is_constexpr((type)1)

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)