RE: [PATCH 3/7] compiler.h: Add __if_constexpr(expr, if_const, if_not_const)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Linus Torvalds
> Sent: 24 July 2024 20:49
> 
> On Wed, 24 Jul 2024 at 07:30, David Laight <David.Laight@xxxxxxxxxx> wrote:
> >
> > Implemented using _Generic() for portibility.
> 
> I do think this is ultimately the clearer implementation, if only
> because the underlying trick it uses does very much depend on a very
> special oddity in the C type system.
> 
> So then using the type comparison with _Generic() is rather natural,
> and allows for picking other things than 0/1 as a result.
> 
> However, there is NO WAY this is a "portability" enhancement.

The old code relied on sizeof(void) which is invalid C.

So this version can be used when that gcc extension isn't enabled.
While the linux kernel rather assumes it other builds (eg nolibc) don't.

	David

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




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux