I have started using a combination of C# and C++ DLLs (VC6) for running the computational part of my image processing tasks in C#. As it is very easy to use C++ DLLs in C# using DLLImport, I have run into a problem. It appears to me that only a limited number of types can be used in the creation of this DLL.
I start by opening the VC6 wizard and choose the Win32 DLL project. From there, I next choose the third option of a simple DLL with some exported symbols.
What I am trying to do is to try to use the string type. I have created a very simple function that returns a string of characters. My function is below:
extern "C" __declspec(dllexport) char* testStr(void);
When I use char* in the prototype, the code compiles with no problem. Next I try
extern "C++" __declspec(dllexport) char* testStr(void);
Also no problem. Next I try
extern "C" __declspec(dllexport) string testStr(void);
I get a compilation error. Same if I do
extern "C++" __declspec(dllexport) string testStr(void);
I have included all the headers in the declarations
but I still get the compiling error. Is there a way around this? I can work with the char* approach if required but I would prefer to use string and have the same/similar types in the unmanaged and managed part of my code. Is there a simple reason for this compiling error?
Can someone post the correct syntax of how this should be done?