translate a macro to D
Trass3r
un at known.com
Thu Jul 7 08:54:40 PDT 2011
> The TYPESIZE macro is used within another macro which defines constants.
> #define M(a,b,size) \
> ((a) << SHIFT_A) | \
> ((b) << SHIFT_B) | \
> ((size) << SHIFT_SIZE))
> #define MM(a,b,type) M((a),(b),(TYPESIZE(type)))
>
> Example:
> #define C1 MM(1, 2, struct A)
> #define C2 MM(3, 4, struct B)
>
> How can I translate that to D?
You could just get rid of that extra macro and directly pass A.sizeof.
Otherwise you need to use templates.
Can't say more cause I can't imagine what the heck this code is used for.
More information about the Digitalmars-d-learn
mailing list