need clarification: will typedef, C struct initialization, etc.
Lars T. Kyllingstad
public at kyllingen.NOSPAMnet
Wed Jun 2 23:58:02 PDT 2010
On Thu, 03 Jun 2010 00:02:03 +0200, Simen kjaeraas wrote:
> On Wed, 02 Jun 2010 23:12:38 +0200, Adam Ruppe
> <destructionator at gmail.com> wrote:
>
>> On 6/2/10, Simen kjaeraas <simen.kjaras at gmail.com> wrote: *snip*
>>
>> I haven't tried your code, but it looks similar to my own code, which
>> had this problem:
>>
>> alias Typedef!Int Handle;
>> alias Typedef!Int OtherHandle;
>>
>> void foo(Handle h) { }
>>
>> OtherHandle b;
>>
>> foo(b); // compiles, but shouldn't. Problem is that Handle and
>> OtherHandle are both alias of the same underlying thing, so the
>> compiler considers them the same thing! With the old typedef, I'm
>> pretty sure it would (correctly IMO) complain here.
>
> My code sidesteps that by including instantiation line and file, making
> each instantiation unique (as long as you don't do multiple typedefs on
> one line).
Cool trick! :)
-Lars
More information about the Digitalmars-d
mailing list