Index: sys/sys/cdefs.h =================================================================== RCS file: /cvsroot/src/sys/sys/cdefs.h,v retrieving revision 1.144 diff -u -r1.144 cdefs.h --- sys/sys/cdefs.h 18 Sep 2019 15:06:03 -0000 1.144 +++ sys/sys/cdefs.h 19 Sep 2019 11:39:04 -0000 @@ -172,8 +172,15 @@ #define __CTASSERT99(x, a, b) __CTASSERT0(x, __CONCAT(__ctassert,a), \ __CONCAT(_,b)) #endif -#define __CTASSERT0(x, y, z) __CTASSERT1(x, y, z) -#define __CTASSERT1(x, y, z) typedef char y ## z[/*CONSTCOND*/(x) ? 1 : -1] __unused +#define __CTASSERT0(x, y, z) __CTASSERT1(x, y, z) +/* + * Compilers accept 'typedef char x[n]' where n is not constant + * at compile time. Use bit-field to enforce compile-time constant. + */ +#define __CTASSERT1(x, y, z) \ + typedef struct { \ + unsigned int y ## z : /*CONSTCOND*/(x) ? 1 : -1; \ + } y ## z ## _struct __unused /* * The following macro is used to remove const cast-away warnings