[fpc-pascal] Re: using macros

dhkblaszyk at zeelandnet.nl dhkblaszyk at zeelandnet.nl
Tue Oct 2 12:02:24 CEST 2012


On 1 okt '12, dhkblaszyk at 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,

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 :

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

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


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20121002/1b4c5012/attachment.html>

More information about the fpc-pascal mailing list