I'm calling C++ from Idris. It's working fine, mostly, but while I can use short strings fine, long strings get mangled. Here's my code
// C++
extern "C" {
const char* foo() {
std::string res = "foo";
return res.c_str();
}
}
and
-- idris
%foreign "C:foo,libfoo"
export
foo : String
main : IO ()
main = printLn foo
"foo"
prints fine, but "fooooooooooooooo"
prints "\65533\65533\65533\SOH"
.