cbindgen
cbindgen copied to clipboard
Support calling convention specification
I am a native rust coder so take this with a grain of salt:
My understanding is that when you are creating a library it is best practice to define the calling convention because someone may be using a different default and then when they try to link with your code it will fail without first re-writing your header.
It should be possible to just add __cdecl if it is extern "C" or __stdcall if it is extern "stdcall" and so on.
Specifically the request here is to allow explicitly saying __cdecl on functions, since right now function prefix/postfix settings won't allow putting this into the declarations.
Relates to #55
It would be useful to always specify the calling convention.
I came across this issue because I hit linker errors with unresolved externals because somebody was passing the /Gz flag to VC++. This option says "make all unannotated functions stdcall" and my Rust functions were compiled with the default (cdecl).
For now I think my only option is to edit the cbindgen generated header because I can't know which compiler flags will be used.
@lzybkr Feel free to send a patch with an option to specify the concrete calling convention, that seems like a reasonable use-case.