version and extern problems

Russell Lewis webmaster at villagersonline.com
Tue Jul 10 10:36:15 PDT 2007


Walter Bright wrote:
> Carlos Santander wrote:
>> I'm guessing this would be the default calling convention for the 
>> system. If the system was written in C++ (BeOS?), would it have to 
>> mean "extern(C++)"? If someone wrote an OS in D, would it just be 
>> "extern(D)"? Or would it just be specified that "System" means 
>> "Windows" on Windows and "C" everywhere else?
> 
> No, it would be what is necessary to interface to packages that pick 
> pointless things like "Windows" calling conventions. If lots of C 
> packages used "FooBar" calling conventions on XXX, then it would mean 
> "FooBar" on that system.

By this argument, it could just as easily be called "Broken".  I am 
concerned that calling it "System" will encourage widespread use...which 
is a step in exactly what you said was the wrong direction.

Did you see the post about using strings for extern?  That seemed like 
an elegant solution to me:

version(Windows)
   const char[] myExternAlias = "Windows";
else
   const char[] myExternAlias = "C";

extern(myExternAlias) void foo();



More information about the Digitalmars-d mailing list