I recently read that using flexible array members in C was poor software engineering practice. However, that statement was not backed by any argument. Is this an accepted fact?
(Flexible array members are a C feature introduced in C99 whereby one can declare the last element to be an array of unspecified size. For example: )
struct header {
size_t len;
unsigned char data[];
};
As a side note, for C89 compatibility, such structure should be allocated like :
Or with macros :
Setting FLEXIBLE_SIZE to SIZE_MAX almost ensures this will fail :