pass a struct using extern C on a . dll c++

Asked

Viewed 70 times

0

I have a function that comes from a . lib that returns me a struct

tabela GSTV(vector<double> inpA, vector<double> inpB);

this struct is defined as follows::

struct tabela {

    vector<int> Z;
    vector<double> F;
    vector<double> S;
    vector<double> Y;


};

But I’m turning this . lib into a . dll with extern "C"

When I have for a vector I usually do:

vector<int> GSTV(vector<double> inpA, vector<double> inpB);

become

extern "C" MINHADLL_API void GSTV( vector<double> inpA, vector<double> inpB, vector<int> &GSTV_ans);

And so by the argument I Gero my vector, however for a struct that is not working.

1 answer

1


It seems we only had to declare one extern "C" of struct in the header of .dll also:

extern "C" struct tabela;

so far as I understand it converts the struct of .lib original and works correctly the code.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.