On 1 okt '12, dhkblas...@zeelandnet.nl wrote: 

> I need to
translate this: #define mymalloc(x,y) (x*)malloc((y)* sizeof(x)) 
> 
>
Is it possible using macro's in FPC or do I need to convert it to a
procedure? How would I cast the pointer in the latter case (without
having to change the sourcecode significantly)? 
> 
> Regards,
Darius

Thanks all, I decided to use an inline function and not to cast
the return pointer. However, I've got another interesting one. Does
someone have an idea how I could implement this? 

#define MYPRINT(var1)
printf(# var1 ":%dn", var1) 

Calling the macro as such :
MYPRINT(sizeof(int)); 

will yield: sizeof(int):4, which is useful for
debugging. 

Will I need RTTI for this? I never used it before so I
might be wrong. 

Darius

  
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to