extern(Windows) alias bug

John C johnch_atms at hotmail.com
Tue May 30 03:11:50 PDT 2006


Lionello Lunesu wrote:
> John C wrote:
> 
>> The following are not equivalent, though I can't understand why not.
>>
>> template TFunc1() {
>>   extern(Windows) alias int function(int) TFunc1;
>> }
>>
>> alias int function(int) funcA;
>> template TFunc2() {
>>   extern(Windows) alias funcA TFunc2;
>> }
>>
>> void main() {
>>   writefln(TFunc1!().mangleof); // PWiZi
>>   writefln(TFunc2!().mangleof); // PFiZi
>> }
>>
>> So the extern(Windows) gets applied to TFunc1, but not TFunc2.
> 
> 
> I think you put the "extern" on the wrong place:
> 
> template TFunc1() {
>   alias extern(Windows) int function(int) TFunc1;
> }
> 
> alias int function(int) funcA;
> template TFunc2() {
>   alias extern(Windows) funcA TFunc2;
> }
> 
> alias extern(Windows) int function(int) funcB;
> template TFunc3() {
>   alias funcB TFunc3;
> }
> 
> void main()
> {
>   writefln(TFunc1!().mangleof); // PFiZi
>   writefln(TFunc2!().mangleof); // PFiZi
>   writefln(funcA.mangleof); // PFiZi
>   writefln(funcB.mangleof); // PFiZi
>   writefln(TFunc3!().mangleof); // PFiZi
> }
> 
> L.

No, "extern" has to go before "alias". In your code the calling 
convention has been ignored. And mangleof shows that: 'F' signifies 
functions with the D calling convention, 'W' functions with the Windows 
calling convention.



More information about the Digitalmars-d-bugs mailing list