-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Need calling convention for stdcall methods (different from functions!) #1342
Comments
|
Notably, the MIDL compiler seems to have no problem annotating |
MSVC for C actually suffers from the same issue. I tested it myself. Functions in COM that return structs have incorrect behavior when called from the official Microsoft C bindings using the MSVC compiler. I'm assuming nobody at Microsoft noticed or cared about this since very few people use C when working with COM. |
What about |
@DemiMarie |
It turned out that the workaround I use for this in winapi was actually slightly wrong. When the function takes parameters beyond |
Hi everyone, any updates on this? Still not sure how to fix Bastacyclop/rust_box2d#3 . Do I need to transform |
The crux of the matter is that stdcall methods on Windows using msvc handle struct returns differently than stdcall functions. This is particularly noticeable in COM, where although most of COM doesn't use struct returns, a few of them do, causing incorrect behavior when you attempt to call them from Rust (or even C for the matter).
Thus I propose that we add a new calling convention specifically for stdcall methods. When faced with this new calling convention Rust should do what Clang does:
Relevant discussion in #LLVM https://gist.github.com/retep998/604861ea06aa984ee6c7
Relevant discussion on discourse https://internals.rust-lang.org/t/need-custom-calling-convention-for-com/2389
gist demonstrating the calling convention difference: https://gist.github.com/retep998/9503145841a61551d3c6
The text was updated successfully, but these errors were encountered: