I am working on plugin containing functions with string as parameter, such as:
Simba Code:
procedure stringTest ( str :string );
I've made this piece of code to convert Simba's string to regular std::string
Code:
typedef char* SimbaString ;
extern "C" void __declspec(dllexport) strTest( SimbaString str){
using namespace std;
cout << str << endl;
int *pLen = reinterpret_cast<int*>(str)-1;
cout << pLen << endl;
int Len = *pLen;
cout << Len << endl;
if (Len > 0) {
string s = string(str,Len);
} else {
cout<<"0 length"<<endl;
}
}
and it works until I pass an empty string. Then it gives an access violation, even on first "cout" line.
I have no idea how to fix that. Please help.