This is the mail archive of the
mailing list for the glibc project.
Re: static_assert in c89 and c99
- From: Rich Felker <dalias at libc dot org>
- To: Lars Gullik BjÃnnes <larsbj at gullik dot org>
- Cc: libc-alpha at sourceware dot org
- Date: Thu, 5 Feb 2015 16:42:41 -0500
- Subject: Re: static_assert in c89 and c99
- Authentication-results: sourceware.org; auth=none
- References: <87wq3x27di dot fsf at black dot gullik dot net> <20150204143535 dot GV23507 at brightrain dot aerifal dot cx> <87siek1xxw dot fsf at black dot gullik dot net>
On Thu, Feb 05, 2015 at 10:59:07AM +0100, Lars Gullik BjÃnnes wrote:
> >> In assert.h static_assert is always defined when __USE_ISOC11 is defined
> >> and that is unconditionally defined by _ISOC11_SOURCE. For a library
> >> feature that would be ok, but since static_assert is using
> >> _Static_assert its usability is really controlled by the compiler and
> >> -std=c11.
> >> I think the static_assert define must be guarded by a check that
> >> -std=c11 really is in effect.
> | If glibc is providing static_assert using _Static_assert on compilers
> | which don't implement the latter, that should probably be fixed. It
> | could be done using _Static_assert conditionally on __GNUC__>=x ||
> | __STDC_VERSION__>=C11, with a fallback to an old method like the dummy
> | type declaration with possibly-invalid array size.
> Gcc 4.6 got support for _Static_assert unconditionally.
> We se the problem since we are (unfortunately) forced to use gcc 4.4.
Then I think glibc should check for 100*__GNUC__+__GNUC_MINOR__<406
and use an alternate definition for _Static_assert in that case. Even
if glibc does not support being built with gcc 4.4, it should still
support using gcc 4.4 (and much older) to compile applications against