Using array_length macro outside function

Joseph Myers joseph@codesourcery.com
Mon Feb 4 23:34:00 GMT 2019


On Mon, 4 Feb 2019, Florian Weimer wrote:

> Do not use a statement expression and _Static_assert in array_length,
> so that array_length can be used at file scope and as a constant
> expression.
> 
> The compiler error message looks like this, so this is still
> acceptable:
> 
> t.c:3:28: error: zero width for bit-field ‘ARGUMENT_NOT_AN_ARRAY’
>    0 * sizeof (struct { int ARGUMENT_NOT_AN_ARRAY: \

You can use _Static_assert inside a struct; you don't need to do things 
with bit-field sizes.

-- 
Joseph S. Myers
joseph@codesourcery.com


More information about the Libc-alpha mailing list