Hello Philip,
Le 18 déc. 2013 à 16:41, Philip Herron <redbr...@gcc.gnu.org> a écrit : > Hey all > > Been writing more rust to learn more. And i have been attempting to > write python bindings to rust. And for example > > if i create a function in rust: > > pub fn spam () { > ... > } > > the symbol gets mangled to: > > redbrain@pherron-mtfdev-vbox {~/workspace/python-rs} $ nm -s spam.o > 0000000000000000 t _ZN4spam19h46502db08befd726ah4v0.0E > > Looks almost similar to the C++ abi at least the _ZN stuff does. Is > there any way to make a function be compiled to a C abi. There is a way to at least disable the name mangling, using the #[no_mangle] attribute: #[no_mangle] fn foo() { ... } The symbol name in the binary will be what you expect. > > I know when we do soemthing like: > > extern { > fn Py_Initialize (); > } > > Calling into the Python api it knows to use the C ABI. Is there anyway > to make a normal rust function to use the C ABI as i want to write a > rust module which can be loaded by python just to see if i can more > than anything. I believe there is also the following syntax: extern "C" fn foo() { } where C matches a specific ABI. according to Rustc, the available are : [cdecl, stdcall, fastcall, aapcs, win64, Rust, C, system, rust-intrinsic] Leo > > As currently if i continue python won't be able to load it i dont > think at least anyways. > > --Phil
signature.asc
Description: Message signed with OpenPGP using GPGMail
_______________________________________________ Rust-dev mailing list Rust-dev@mozilla.org https://mail.mozilla.org/listinfo/rust-dev