extern(Windows) behavior on non-Windows systems

via Digitalmars-d digitalmars-d at puremagic.com
Thu Jun 12 08:13:43 PDT 2014


On Wednesday, 11 June 2014 at 22:20:27 UTC, Walter Bright wrote:
> I've got an enhancement request to have it behave like 
> extern(C):
>
>     https://issues.dlang.org/show_bug.cgi?id=12894
>
> Thoughts? Anyone use extern(Windows) on non-Windows systems?

That example of "I want this calling convention on platform X and 
that other convention on platform Y" points to the deeper problem 
that (without a preprocessor) you can't do something like this in 
D:

     version(Windows)
         alias extern(Foo) = extern(Windows);
     else
         alias extern(Foo) = extern(C);

     extern(Foo):
         void foobar();
         int baz();

That reasoning also applies to various other attributes. IMO, 
repeating all of the declarations for the multiple variants you 
might want is not the right answer (DRY principle, etc.).


More information about the Digitalmars-d mailing list