Date: Wed, 21 Apr 2021 06:22:38 +0000 From: bugzilla-noreply@freebsd.org To: standards@FreeBSD.org Subject: [Bug 255290] _POSIX_C_SOURCE=200809 hides static_assert Message-ID: <bug-255290-99@https.bugs.freebsd.org/bugzilla/>
next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D255290 Bug ID: 255290 Summary: _POSIX_C_SOURCE=3D200809 hides static_assert Product: Base System Version: Unspecified Hardware: Any URL: https://github.com/gbdev/rgbds/issues/789 OS: Any Status: New Severity: Affects Only Me Priority: --- Component: standards Assignee: standards@FreeBSD.org Reporter: tobik@freebsd.org $ cat test.c <<EOF #include <assert.h> int main() { static_assert(1 =3D=3D 1, ""); } EOF $ cc -D_POSIX_C_SOURCE=3D200809L -std=3Dgnu11 test.c test.c:2:14: warning: implicit declaration of function 'static_assert' is invalid in C99 [-Wimplicit-function-declaration] int main() { static_assert(1 =3D=3D 1, ""); } ^ 1 warning generated. ld: error: undefined symbol: static_assert >>> referenced by test.c >>> /tmp/test-8e234d.o:(main) cc: error: linker command failed with exit code 1 (use -v to see invocation) This affects devel/rgbds where I had to remove _POSIX_C_SOURCE. In assert.h we have: #if __ISO_C_VISIBLE >=3D 2011 && !defined(__cplusplus) #define static_assert _Static_assert #endif In sys/cdefs.h we have: #if _POSIX_C_SOURCE >=3D 200809 #define __POSIX_VISIBLE 200809 #define __ISO_C_VISIBLE 1999 so static_assert is hidden when _POSIX_C_SOURCE=3D200809L because __ISO_C_VISIBLE is clamped to 1999. I've reported this upstream but we have found no evidence that POSIX 2008 mandates C99 and should hide static_assert. On Linux with musl and glibc and OpenBSD this works fine. OpenBSD uses __STDC_VERSION__ instead of __ISO_C_VISIBLE in assert.h which might be the more correct choice. --=20 You are receiving this mail because: You are the assignee for the bug.=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-255290-99>