Returning a QString to a QLibrary
I am using a shared library and load it using QLibrary. That requires that the functions be exported with extern "C". However, the function
Code:
extern "C" QString objectName
(long type
);
gets a compiler warning
Quote:
'objectName' has C-linkage specified, but returns UDT 'QString' which is incompatible with C
Is there a way to export a QString return from a shared library? I would prefer not defeating a really good class like QString.
Re: Returning a QString to a QLibrary
It is because of 'extern "C"'. Why do you need this extern C? As the error says you can't use QString as it is not compatible with C which is totally right as QString is a class.
Re: Returning a QString to a QLibrary
simple: you have to use char* and conversions like QString::toUtf8
Re: Returning a QString to a QLibrary
Yes, I've used the dual conversion already. I was just hoping that there was a better to export it; QLibrary could have been written to resolve the transformation. Thanks