-
Notifications
You must be signed in to change notification settings - Fork 328
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support non-C calling conventions #55
Comments
This seems reasonable to me. What needs to be output for |
According to msdn the syntax looks like this: I haven't used the C pre-processor for much more than conditional compilation and Alternatively, you could add an extra flag to the config struct which takes a Awesome project by the way. I originally made something similar because |
Hmm, so I think we can generate the following to handle this: #ifndef _MSC_VER
// might need some fudging depending on where the attribute needs to go in the function declaration.
#define __stdcall __attribute__((stdcall))
#endif Seeing as |
That's quite a nice solution. I'm assuming those I'll see if I can start working on a PR for this tomorrow. |
@eqrion, do you have anything in mind for how to add support for calling conventions into I think this is all I need to do to add support for calling conventions:
... Is that about it? |
@Michael-F-Bryan Yes, that sounds reasonable to me. You'll need to have a pass to detect what macros should be declared at the top, and it'd be best if this worked after we eliminated unused items (the dependency pass). That can most likely go in Library (1) where I've put other passes like that. Maybe accumulate them into a set of flags or a struct of bool fields that gets passed onto Bindings, where we write it out at the beginning? Thanks for looking into this! The code isn't the best organized, it's evolved to support a bunch of random features people have wanted quickly. |
We ended needing this feature as well but in our case we had to use From FFI nomicon:
It'd be great if we could handle this gracefully. |
I'm trying to export some Rust functions as a DLL to be used in a larger application, but instead of the usual
extern "C"
calling convention, I'm usingstdcall
. Withstdcall
,cbindgen
doesn't emit declarations.Would it be possible to tweak the rules so
cbindgen
will make bindings for anything markedextern
and#[no_mangle]
, no matter the calling convention? I don't think there's any time you wouldn't want bindings for a function markedextern
.This looks like it's related to #49, but affects all forms of
extern
, not just where the"C"
is omitted.The text was updated successfully, but these errors were encountered: