The declaration of struct ofp_connect violates the following clause of the ISO C standard:
6.7.2.1 Structure and union specifiers ... 18 As a special case, the last element of a structure with more than one named member may have an incomplete array type; this is called a flexible array member.
Note that in your case in_port
and out_port
should have been declared as in_port[]
and out_port[]
to take advantage of the clause above in which case you would have two flexible array membes, which is prohibited by the above clause. The zero-length array declaration is a convention adopted by many compilers (including gcc, for example) which has the same semantics but in your case, both in_port
and out_port
share the same space (essentially whatever bytes follow the ofp_connect
structure). Moreover, for this to work, you have to allocate some space after the structure for the flexible array members. Since, as you said, struct connect
is part of a larger structure, accessing in_port
returns the 'value' stored in the containing structure's member following the connect
sub-struct