Re: git: d1f1402dff63 - main - libnetbsd: import `__CTASSERT(..)` macros

From: Gleb Smirnoff <glebius_at_freebsd.org>
Date: Tue, 24 Feb 2026 17:54:55 UTC
On Sat, Feb 21, 2026 at 09:53:14AM -0800, Enji Cooper (yaneurabeya) wrote:
E> > FYI, _Static_assert is not a FreeBSD-ism, it's part of C11.  Our old CTASSERT is
E> > a FreeBSD-ism that this extends, but really, these should be implemented in
E> > terms of _Static_assert when possible.  Something like:
E> > 
E> > #if is_c11
E> > #define __CTASSERT(x)  __Static_assert(x)
E> > #else
E> > /* all the rest */
E> > #endif
E> > 
E> > If __CTASSERT0 is used directly anywhere, you could emulate it via something like
E> > 
E> > #define __CTASSERT0(x, y, z)  __Static_assert(x, __STRING(y) "_" __STRING(z))
E> > 
E> > (Note that we build all of userspace as C17 by default in 15.0 and later.)
E> 
E> 
E> Hi jhb@!
E> 
E> Excellent points. Incorporating our macros/adaptations can cause grief sometimes and I don’t want to porting more code than necessary, so I have incorporated these macros (and a few others) wholesale from NetBSD (I got these from [1]).
E> 
E> -Enji
E> 
E> 1.  https://github.com/NetBSD/src/blob/c26cc77b3a0b26b95a2df2e0154e2b2f7292ab20/sys/sys/cdefs.h#L168-L182

I don't expect any grief if __CTASSERT() is implemented via __Static_assert().

-- 
Gleb Smirnoff