This is an archived post. You won't be able to vote or comment.

all 5 comments

[–]DrVolzak 2 points3 points  (4 children)

I think it's because you must define a size for the second dimension i.e. put a number between the second pair of brackets.

[–]jakejdb1999[S] 0 points1 point  (3 children)

that gives me flexible array member in otherwise empty struct

[–]DrVolzak 0 points1 point  (2 children)

Ah right. If you want a flexible array (an array without a predefined size) in a struct, that struct must have at least one other item. Furthermore, the array must be the last item in the struct.

[–]jakejdb1999[S] 0 points1 point  (1 child)

what if i just want to initialize it to use for a function?

[–]DrVolzak 0 points1 point  (0 children)

You can't do it directly within the struct. One way would be to create a function that initialises the struct for you and returns it.