bitwiseworks / libc

LIBC Next (kLIBC fork)
9 stars 4 forks source link

C11 static_assert macro is missing in assert.h #131

Closed komh closed 1 year ago

komh commented 1 year ago

C11 defines static_assert as a macro in assert.h. However, libc does not have it.

BTW, static_assert is a keyword since C23.

Please implement this.

dmik commented 1 year ago

Could you please provide a test case for that? This is how GLIBC does that but I want to make sure it will work for us as well: https://sourceware.org/git/?p=glibc.git;a=blobdiff;f=assert/assert.h;h=4022e28b55e24205d04c87fea6350310820befdb;hp=841f435973aa831a55aacf03c5a3c534ba7763c4;hb=839e283ece8f4a8312dd6c558df8c739356fddb7;hpb=90fa7312770b1caca8843a55a9c3825585aac140

dmik commented 1 year ago

But we should perhaps go after FreeBSD as we have more in common with them: https://github.com/freebsd/freebsd-src/blob/de1aa3dab23c06fec962a14da3e7b4755c5880cf/include/assert.h#L63

dmik commented 1 year ago

Note that this task actually also requires bumping __ISO_C_VISIBLE to 2011 in sys/cdefs.h. I will also grab this part from FreeBSD as our sys/cdefs.h is a very close descendant of it. This might break a thing or two in some stuff we build but it should be easily fixable. Note that GCC enables C11 mode by default since very long (since GCC 5.5 according to this comment), this includes our "officially" supported GCC 9.x.