This repository has been archived by the owner on Feb 8, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
interop with C++ std::string #28
Comments
Much of the Octave API uses std::strings, so I think this will be pretty much required to get a useful binding working anyway. Even if you could get past the function call registration part of this, it would be hard to get the value of a string argument passed in to your function without std::string. |
This was referenced Sep 29, 2017
Reviewing this two years later, it looks like I should pursue the answer to the question I asked at https://stackoverflow.com/q/46524781/23059 I think I'm doing the interop wrong here for #18: let name = CString::new("add").unwrap();
let pname = name.as_ptr() as *const octh::root::std::string;
std::mem::forget(pname);
let doc = CString::new("adds inputs and returns sum to all outputs").unwrap();
let pdoc = doc.as_ptr() as *const octh::root::std::string;
std::mem::forget(pdoc);
let fcn = octh::root::octave_dld_function_create(Some(Fadd), shl, pname, pdoc); It is creating string string_create(char* a)
{
string s(a);
return s;
} Or wrap |
ctaggart
added a commit
that referenced
this issue
Nov 18, 2019
This was referenced Nov 19, 2019
Merged
ctaggart
added a commit
that referenced
this issue
Nov 21, 2019
* added stdstring_new * add octave_value type helpers * remove stdstring_new that did not work #28 * print all arg types * added helloworld example * started Rust API
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The string interop is not currently correct. I'm not sure why I thought this might work.
https://github.com/ctaggart/octh_examples/blob/723cfaf9fc6d16e0c0caec6148ecf1e1dbc62831/src/lib.rs#L11-L13
I think we have to disable
.opague_type("std::.*")
in build.rs in order to create bindgen forstd::string
. This opens up a can of worms though:sentry
is defined multiple times #29 error[E0428]: the namesentry
is defined multiple times_CharT
in this scope #8 cannot find type_CharT
in this scopeThe text was updated successfully, but these errors were encountered: