Dynamic arrays in Struct in DPI-C

714 Views Asked by At

I want to use a dynamic array inside a struct which i pass onto C using DPI.

How do i implement it on C-side. I tried using svOpenArrayHandle inside struct but still not working. Example:

Struct a {
    int x;
    int y[];
}
1

There are 1 best solutions below

0
dave_59 On BEST ANSWER

According to LRM section 35.5.6 Types of formal arguments, structs may only contain the types listed in that section. Dynamically sized arrays is not one of them.

It would be much easy to pass an array of int, then unpack into a legitimate C struct.