fastcall?

Post Reply
User avatar
IXix
Posts: 1113
Joined: Wed Nov 23, 2011 3:24 pm

fastcall?

Post by IXix »

I seem to remember Oskari saying something along the lines of "machines should no longer use the fastcall calling convention" but I can't remember what was said. It was a long time ago, maybe on BuzzChurch?

Looking through my machines, the only one that doesn't use fastcall is IX Split (uses cdecl) but they all seem to work okay. I ask because I've been getting weird random exceptions when I'm debugging magic, ever since I started using VS2018. Wondering if the calling convention might be an issue.
User avatar
UNZ
Posts: 809
Joined: Mon Nov 21, 2011 9:42 pm
Contact:

Re: fastcall?

Post by UNZ »

i'm even using vectorcall and it seems to work... but the documentation for that says it doesn't touch member functions by default.. (so they remain thiscall i guess). There seem to be no such guarantees for fastcall however... so maybe just switch to vectorcall and see.

https://docs.microsoft.com/en-us/cpp/cp ... ew=vs-2019
https://docs.microsoft.com/en-us/cpp/cp ... ew=vs-2019

in any case, as long as you decorate your buzz-interfacing functions as cdecl, it should work and you can use whatever other calling convention for the rest of your application. machineinterface.h already specifies cdecl for some functions (like GET_INFO or CREATE_MACHINE), so if you implement them as cdecl everything should be fine imho, at least up to the point of creating the machine.

Would be good if Oskari could clarify tough what calling convention should be used for implementations of CMachineInterface/CMachineInterfaceEx/CMICallbacks etc (thiscall? i think that's standard for member calls anyway, but might get mangled by having /Gr on fastcall?). Until then i would just try to see if you still get crashes if you switch to /Gv. Also you should notice that functions get called with seemingly wrong arguments if you use the wrong calling convention.
User avatar
IXix
Posts: 1113
Joined: Wed Nov 23, 2011 3:24 pm

Re: fastcall?

Post by IXix »

UNZ wrote: Tue Apr 21, 2020 9:05 am i'm even using vectorcall and it seems to work...
Thanks! I'm not a real programmer so much of this stuff is still a bit of a mystery to me. I've never even heard of vectorcall! :lol:

Hoping Oskari will chime in to clarify.
Post Reply