On Saturday, 6 March 2021 at 12:15:43 UTC, Mike Parker wrote:
On Saturday, 6 March 2021 at 11:57:13 UTC, Imperatorn wrote:
What... Is this really how it's supposed to be? Makes no sense
to not use any of the existing conventions.
extern(C) and extern(D) are both documented to be the same as
the platform's C calling convention everywhere except x86
windows:
https://dlang.org/spec/abi.html#function_calling_conventions
There have been times when differences were noted (I recall a
particularly bad one related to passing structs by value on
64-bit linux) and there may be more. When they are, they should
be reported in Bugzilla.
The main difference is that the params are reversed for
extern(D), at least with DMD and LDC, not with GDC. And that
can't be easily changed because of all the naked DMD-style inline
asm code (GDC doesn't support that, so no problem for GDC). This
comes up regularly here in this forum whenever people experiment
with DMD-style asm.
There are other slight breakages of that 'spec', e.g., LDC's
extern(D) ABI is very similar to Microsoft's __vectorcall (so
that e.g. vectors are passed in registers).