Olórin
Olórin

Reputation: 3814

Interop of C structure with Fortran

Let's say I have this C structure :

struct
{
    union
    {
        unsigned char *lpbData; /* data passed to XL */
        void* hdata;            /* data returned from XL */
    } h;
    long cbData;
} bigdata;  

and that I have to "interop" it with Fortran. How can I do this ?

(I could create a Fortran structure containing a Union (my Fortran compiler knows the Union extension) but the Union cannot contain anything allocatable, nor a pointer ....)

Upvotes: 2

Views: 220

Answers (1)

steve
steve

Reputation: 900

You can't. From Fortran 2018, page 476.

There is no Fortran type that is interoperable with a C structure type that contains a bit field or that contains a flexible array member. There is no Fortran type that is interoperable with a C union type.

Upvotes: 3

Related Questions