I am trying to pass two Strings
from Swift to the C++ function, handle them there, and then return an array of integers (probally a vector), not sure yet.
I've tried it with (C++ function declaration):
void exmaple(char* one, char* two);
But was not able to pass the strings from Swift to C++.
Then I changed the function a little:
void example(void* one, void* two)
{
string &a = *reinterpret_cast<string*>(one);
string &b = *reinterpret_cast<string*>(two);
cout<<"String b is: "<<b<<endl;
}
and tried calling the function in Swift:
let aStr = UnsafeMutablePointer<String>.alloc(10)
aStr.initialize("stringA")
let bStr = UnsafeMutablePointer<String>.alloc(10)
bStr.initialize("stringB")
example(aStr, bStr)
But the only output I get is:
String b is:
How can I pass two Strings from Swift to a C++ function, and then return an array/vector of integers?