A "popular extension" which most implementations can be configured to support (if they don't always do so) is to allow the address of structure type to be converted to the address of another which shares a Common Initial Sequence, and be used to access members of that sequence, until the structure is accessed via means other than the converted pointer, or execution enters a function or loop wherein that would occur.
On implementations that support that extension, the requested semantics can be achieved by declaring a structure whose layout which matches that of the structure with the Flexible Array Member. For example:
struct POINT { int x, y; }; struct POLYGON { int sides; struct POINT coords[]; }; struct TRIANGLE { int sides; struct POINT coords[3]; }; void draw_polygon(struct POLYGON const *p); void test(void) { struct TRIANGLE my_triangle = {3, {{1,2}, {3,4], {5,6}}; draw_polygon((struct POLYGON*)&my_triangle); }
Some compilers like icc and MSVC are sophisticated enough to support this extension even when type-based aliasing is enabled. Others like gcc and clang can only support this extension via the use of the -fno-strict-aliasing option.
Although code using this extension is not strictly conforming, the Standards Committee has said in the published Rationale that they did not want to make the language usable only for writing portable programs. Instead, they expected that quality implementations would support a variety of "popular extensions" by processing some constructs in ways that would be useful to their customers even when the Standard would allow them to do otherwise. The ability to convert pointers among structure types has been a fundamental part of the language the Standard was written to describe since 1974, and nearly all implementations can be configured to support it. Code like the above should thus be recognized as more portable than code which relies upon non-standard syntactical extensions to achieve similar semantics.
struct test *myText = malloc(size * sizeof (*myText))?struct test *myStruct = myText + 1;inotifyfile descriptor files supplied buffer withstruct inotify_eventwhich contains flexible array member.