[Bug 255290] _POSIX_C_SOURCE=200809 hides static_assert

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Wed Apr 21 20:06:07 UTC 2021


--- Comment #11 from Warner Losh <imp at FreeBSD.org> ---
> As far as I'm aware, C11 does not make any modifications to the standard that are incompatible with POSIX 2008, and thus there are no conflicts, and hence, no undefined behavior.

C11 adds things. Those additions intrude into the namespace that POSIX allows
the user to use. That's where the conflict arises.

The following should be a strictly conforming, even if compiled with C11
compiler, as there's no exception in POSIX for newer versions of C introducing
new things. The requested change would make it not be.

#define __POSIX_C_SOURCE 200809

#include <assert.h>
#include <stdio.h>

void static_assert(int a, int b, int c)
{ printf("A is %d, b is %d and c is %d\n", a, b, c);}
int main(int argc, char *argv[]) { static_assert(1, 2, 3); exit(0); }

Further, __STDC_VERSION__ is not a feature test macro that the user can define.
It is a pre-defined macro defined by the compiler, and can't be redefined by
the programmer.

You are receiving this mail because:
You are the assignee for the bug.

More information about the freebsd-standards mailing list