#Do we need explicit callconv keyword to ensure calling conventions are respected?

1 messages · Page 1 of 1 (latest)

molten pollen
#

If I want to make sure a function call respects the x86_64 calling convention (e.g., the first parameter passed in %rdi), do I need to explicitly use callconv(.C)?

latent quest
#

callconv(.c) (it's lowercase as of 0.14) will use the C calling convention for your platform which is both architecture and OS dependent

#

so e.g. windows x86_64 has a different convention

#

if you want to always use the system-v calling convention (rdi, rsi, etc.) you can use callconv(.{ .x86_64_sysv = .{} }) (you can use this even on windows)

#

also any export or extern function is implicitly callconv(.c) unless you specify something else

molten pollen
#

Did you mean to use callconv(.SysV), because the initialization syntax doesn't work, nor is there such an enum variant? I suppose it was for previous Zig versions, mine is 0.13.0 I believe

latent quest
#

SysV is right for 0.13
for 0.14 you can use SysV but it's deprecated, what i wrote is the new way