extern(Windows) alias bug
John C
johnch_atms at hotmail.com
Tue May 30 02:21:56 PDT 2006
Regan Heath wrote:
> On Mon, 29 May 2006 22:50:23 +0100, John C <johnch_atms at hotmail.com> 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.
>
>
> At a wild guess.. doesn't the alias:
> alias int function(int) funcA;
>
> have an implicit "D calling convention" (extern(D)?)
> label/tag/specifier, eg.
> alias extern(D) int function(int) funcA;
>
> so, the alias:
> extern(Windows) alias funcA TFunc2;
>
> really reads something like:
> extern(Windows) alias extern(D) int function(int) TFunc2;
>
> and maybe the later one overrules the former?
>
> Regan
You may be right there. The reason why I wanted this to work is because
this doesn't:
template TFunc(T) {
...
}
TFunc!(extern(Windows) int function(int));
A nice workaround would have been to have another template apply the
calling convention:
template ExternWindows(T) {
extern(Windows) alias T ExternWindows;
}
TFunc!(ExternWindows!(int function(int, char*, char*, int));
I guess I'm now wondering why extern can't be used inline. It'd be
useful in the above situation, and on anonymous function literals.
John.
More information about the Digitalmars-d-bugs
mailing list