passing a struct using extern C in a .dll c ++

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 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 generate my vector, however for a struct this is not working.

    
asked by anonymous 03.04.2018 / 02:57

1 answer

0

It seems like I just needed to declare a extern "C" of struct in the header of .dll also:

extern "C" struct tabela;

In this way I understand that it converts the struct of the original .lib and works correctly the code.

    
03.04.2018 / 03:08