In C99, flexible array members (of a structure) and variable length arrays were mandatory parts of the standard — conforming C99 compilers (implementations) have to support them both.
In C11, an implementation is allowed to define (§6.10.8.3 Conditional feature macros):
__STDC_NO_VLA__
The integer constant 1, intended to indicate that the implementation does not support variable length arrays or variably modified types.
- Does that definition mean that a compiler which specifies that it does not support VLAs is also allowed not to support §6.7.2.1 ¶3 flexible array members either — or are §6.7.2.1 ¶18 flexible array members mandatory even without VLA support?
I've not spotted anywhere in the standard that stipulates that a structure with a FAM is a variably modified type, so I think that even without support for VLAs, a C11 compiler is required to support FAMs. One item in favour of this interpretation: the size of a structure with a FAM is fixed; the FAM is not counted as part of the size (whereas the size of a VLA is not a compile-time constant).
malloc()
et al). I was about to add some code to a 'type size' printing program for both VLA types and structure-with-FAM types and wondered whether the__STDC_NO_VLA__
meant that the FAM code should be left untested. – Jonathan Leffler