digitalmars.D.learn - Clarity about extern(Windows)/extern(System)
- Mike Parker (16/16) Dec 17 2017 For years now, I've been under the impression that the
- Kagamin (3/6) Dec 18 2017 64-bit ABI fixed calling convention proliferation, only one cc is
- Mike Parker (2/8) Dec 18 2017 What about extern(Windows) on 32-bit Posix?
- Kagamin (1/1) Dec 18 2017 https://gcc.gnu.org/onlinedocs/gcc-7.2.0/gcc/x86-Function-Attributes.htm...
- Mike Parker (3/4) Dec 18 2017 Thanks. I was playing around on asm.dlang.org and found there's a
- Kagamin (12/12) Dec 18 2017 From https://gcc.godbolt.org/
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
Dec 17 2017
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.
Dec 18 2017
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:What about extern(Windows) on 32-bit Posix?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.
Dec 18 2017
https://gcc.gnu.org/onlinedocs/gcc-7.2.0/gcc/x86-Function-Attributes.html#index-functions-that-pop-the-argume t-stack-on-x86-32-3 looks like gcc doesn't see it as OS dependent.
Dec 18 2017
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-argume t-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.
Dec 18 2017
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
Dec 18 2017