Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
December 17, 2017 Clarity about extern(Windows)/extern(System) | ||||
---|---|---|---|---|
| ||||
For years now, I've been under the impression that the distinction between extern(Windows) and extern(System) actually mattered. I recall extern(System) was first added to the language to resolve this situation for C bindings: version(Windows) extern(Windows): else extern(C): Which, or course, does not work. Yet, it's now been pointed out to me [1] that the documentation says the following [2]: The Windows convention is distinct from the C convention only on Win32 platforms, where it is equivalent to the stdcall convention. This implies that extern(Windows) and extern(System) behave the same way. My limited testing on a 64-bit Linux VM shows no problems when binding a C function as extern(C) or extern(Windows), and the disassembly looks the same. [1]: https://github.com/Extrawurst/DerelictFmod/pull/3 [2]: https://dlang.org/spec/attribute.html#linkage |
December 18, 2017 Re: Clarity about extern(Windows)/extern(System) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike Parker | On Sunday, 17 December 2017 at 13:36:15 UTC, Mike Parker wrote:
> My limited testing on a 64-bit Linux VM shows no problems when binding a C function as extern(C) or extern(Windows), and the disassembly looks the same.
64-bit ABI fixed calling convention proliferation, only one cc is used there.
|
December 18, 2017 Re: Clarity about extern(Windows)/extern(System) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kagamin | On Monday, 18 December 2017 at 10:52:22 UTC, Kagamin wrote:
> On Sunday, 17 December 2017 at 13:36:15 UTC, Mike Parker wrote:
>> My limited testing on a 64-bit Linux VM shows no problems when binding a C function as extern(C) or extern(Windows), and the disassembly looks the same.
>
> 64-bit ABI fixed calling convention proliferation, only one cc is used there.
What about extern(Windows) on 32-bit Posix?
|
December 18, 2017 Re: Clarity about extern(Windows)/extern(System) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike Parker | https://gcc.gnu.org/onlinedocs/gcc-7.2.0/gcc/x86-Function-Attributes.html#index-functions-that-pop-the-argument-stack-on-x86-32-3 looks like gcc doesn't see it as OS dependent. |
December 18, 2017 Re: Clarity about extern(Windows)/extern(System) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike Parker | From https://gcc.godbolt.org/ __attribute__((stdcall)) int square(int num) { return num * num; } _Z6squarei: push ebp mov ebp, esp mov eax, DWORD PTR [ebp+8] imul eax, DWORD PTR [ebp+8] pop ebp ret 4 |
December 18, 2017 Re: Clarity about extern(Windows)/extern(System) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kagamin | On Monday, 18 December 2017 at 14:31:38 UTC, Kagamin wrote:
> https://gcc.gnu.org/onlinedocs/gcc-7.2.0/gcc/x86-Function-Attributes.html#index-functions-that-pop-the-argument-stack-on-x86-32-3 looks like gcc doesn't see it as OS dependent.
Thanks. I was playing around on asm.dlang.org and found there's a definite difference in 32-bit output.
|
Copyright © 1999-2021 by the D Language Foundation