Clarity about extern(Windows)/extern(System)

Mike Parker aldacron at gmail.com
Sun Dec 17 13:36:15 UTC 2017


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


More information about the Digitalmars-d-learn mailing list