#Struct member with flexible array[]

5 messages · Page 1 of 1 (latest)

heady sluice
#
typedef struct {
    u32 dimension_row_count;
    u32 data_size; /* rowA*rowB...*rowN */
    u32 dimension_row_sizes[];
} matrix_size;

typedef struct {
    matrix_size dimensions;
    double data[];
} MATRIX;

Error: field 'dimensions' with variable sized type 'matrix_size' not at the end of a struct or class

Looks like I am not allowed to have a member with a flexible array within another struct. Why?

lavish frostBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

viscid stratus
#

You effectively have two flexible member, which sizes are unknown, so compiler can’t determine the address of the member

#

If you want that you need to allocate twice, so yes having your member as pointer works

heady sluice
#

!solved