Re: [fpc-pascal] using macros

2012-10-02 Thread Marco van de Voort
In our previous episode, Marco van de Voort said: > 3. There is no way to pass something typeless to a function and then get >the size of it. This make emulating it with functions hard. Btw, Modula2 allows to pass any type of defined size to an ARRAY OF BYTE open array (and thus such functions

Re: [fpc-pascal] using macros

2012-10-02 Thread Marco van de Voort
In our previous episode, dhkblas...@zeelandnet.nl said: A bit late, but: > I need to translate this: #define mymalloc(x,y) (x*)malloc((y)* > sizeof(x)) Impossible. 1. FPC macros can't be parameterized 2. less problematic, but macros don't import over unit borders, you'd have to put the macr

[fpc-pascal] using macros

2012-10-01 Thread dhkblaszyk
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 _