[fpc-pascal] Re: using macros

Lukasz Sokol el.es.cr at gmail.com
Mon Oct 1 17:18:23 CEST 2012


On 01/10/2012 15:21, 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)?
> 
> 
Not that I claim to /know/, but,
Is the purpose of this macro, to substitute 

(something) =  mymalloc(UInt, 5)
with
(something) = (Uint*)malloc(5*sizeof(UInt)) 

in source code (before compiling?) This means (something) is an array?

I'd definitively make it a function.

(haven't we got dynamic arrays for something like that ?)

> 
> Regards, Darius
> 
L.




More information about the fpc-pascal mailing list