Hello everybody,
is it possible to use a struct with flexible array members and declare a variable of it at compile time?
e.g.:
struct sFoo { uint32_t const num_Elements; uint8_t baz[]; } #define DECLAREFOO (name, nElements) \ struct sFoo name = { (nElements), ..?}
what I am using is the following:
struct sFoo { uint32_t const num_Elements; uint8_t * const baz; } #define DECLAREFOO (name, nElements) \ uint8_t name##_container[ (sizePerElement) * (numElements)]; \ struct sFoo name = { (nElements), & name##_container[0]}
Can anyone think of a smarter way to do this without the container or malloc?
Thanks for your replies Alexander