Re: passing using "string" type in DLL Interface
Sarath wrote:
Is there anything wrong in using "string" or wstring in the DLL
interfaces?
No, there are no special problems with those two. However, others already
mentioned certain other problems that are generally applicable.
Further, two more infos:
1. You need two DLLs anyway if you use the typical debug/release scenario.
The reason is that if those are linked against the debug/release variant of
the runtime libraries, those use different heaps and you must not allocate
in one heap and release in the other. The MFC for example uses a 'd' suffix
in their DLLs (mfc42.dll and mfc42d.dll).
2. The problem with the compilers isn't too big. The point is that mixing
output from different compilers will already fail at linktime, so at least
this won't lead to silent corruption or hard-to-track errors. I have
libraries here that work with VC6-VC8, the way it is done is by simply
using different DLL names, i.e. suffixed with -vc6, -vc71 or -vc8. Using
#pragma comment(lib,..) and checking the compiler version (_MSC_VER) makes
this pretty easy and convenient.
Other than that, depending on how big your audience is, you might want to
consider things like COM, which would allow your DLL to be invoked from
VC6-VC8, C#, VB and whatnot. I don't do that though, since I develop for
embedded systems, so I don't want the COM overhead nor do I really need it.
cheers
Uli