-
Hello,
The problem is to initiate the array
I also tried this with no success
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
The first attempt is because it is a struct as you suspect. Structs are selfcontained objects without external references and fixed length arrays in structs are not FlatBuffer vectors. Your second attempt is better. I don't recall the exact syntax but it seems like you are are starting the payload field as a generic Payload union instead of a specific instance of type "Struct2". It would be more along the lines of Also worth noting: normally a struct is stored in the same memory blob as other table fields such as integers, but when it is a union it is allocated separately. The union is two fields: a pointer (offset), and a type. You need to make sure the pointer to the struct is allcoted, and that the type is set. Some of the helper functions do some of that work automatically. Please let me know if this is enough to get you going, or I can dig deeper. |
Beta Was this translation helpful? Give feedback.
-
It is also possible your first example might work if you replace the vector reference with a native C array of the correct type, and leave the creation of the vector. In the documentation, you will see an assign call that takes an array and string as arguments. It should work the same with create calls. |
Beta Was this translation helpful? Give feedback.
It is also possible your first example might work if you replace the vector reference with a native C array of the correct type, and leave the creation of the vector.
In the documentation, you will see an assign call that takes an array and string as arguments. It should work the same with create calls.
https://github.com/dvidelabs/flatcc/blob/master/doc/builder.md#fixed-length-arrays-in-structs