Return struct/string from C to SV

I have a question

1# I want to return a structure from c-model to the SV my structure is here
In SV:

typedef struct {
  string res_data;
  string res_add;
}rfi;

In C:

typedef struct {
  char res_data[32];
  char res_add[32];
}rfi;

and imported in SV using
import “DPI-C” function rfi ref_model(string inst);

I’m getting an error says “unpacked struct can’t be return type”
So when I use
In SV:
typedef struct packed{
string res_data;
string res_add;
}rfi;
getting error:“string can’t be in packed struct”

2# How to return a string type to SV from C?
i’m using::
import “DPI-C” function string ref_model(string inst);
string result;
result=ref_model(inst);
when I print result the simulator(VCS) gets terminating without printing the result…

appreciate if any experts help me, thank you.

SystemVerilog only allows singular types (packed, real, ints) as return types. Dynamically sized types like strings must be passed in a way that memory management is kept independent on both sides of the DPI interface. This is a very advanced topic and you should consult with your vendor for additional help.