extern(C) vs. extern(Windows)

Sean Kelly sean at f4.ca
Mon Apr 2 08:54:30 PDT 2007


Max Samukha wrote:
> On Mon, 02 Apr 2007 19:23:08 +0900, Mike Parker <aldacron71 at yahoo.com>
> wrote:
> 
>> Frits van Bommel wrote:
>>> Frank Benoit (keinfarbton) wrote:
>>>> I have many functions. On linux they shall be extern(C), on win32 they
>>>> shall be extern(Windows). How do I do that?
>>> Put this right above them:
>>> ---
>>> version(Windows) {
>>>     extern(Windows):
>>> } else {
>>>     extern(C):
>>> }
>>> ---
>>> (assuming extern(C) for anything but Windows)
>>>
>>> If any other functions follow them, add "extern(D):" afterwards to 
>>> restore the default calling convention and mangling.
>> As I understand it, you have to do this without the brackets:
>>
>> =====================
>> version(Windows)
>>     extern(Windows):
>> else
>>     extern(C):
>> =====================
> 
> You can use brackets because version does not create a scope.

Right.  It used to for some odd cases, but this has been fixed.


Sean


More information about the Digitalmars-d-learn mailing list