translate a macro to D

teo teo.ubuntu at yahoo.com
Thu Jul 7 13:14:21 PDT 2011


On Thu, 07 Jul 2011 17:54:40 +0200, Trass3r wrote:

>> 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.

ioctl types
BTW: there is no ioctl module within phobos


More information about the Digitalmars-d-learn mailing list