Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2008-03

assitent with Macro translation

4 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

ik

Hello,

I've started binding libsvn to FPC, and I have encountered the following macro that I do not know how to translate: #define APR_ARRAY_IDX(ary,i,type) (((type *)(ary)->elts)[i])

The usage of such macro is as follows:  APR_ARRAY_IDX (new_entries, i,
const char *);

How can I translate the "type" ?

Thanks,
Ido

Reply by email

Marco van de Voort
to ik
Show quoted text 8 lines
I've started binding libsvn to FPC, and I have encountered the following macro that I do not know how to translate: #define APR_ARRAY_IDX(ary,i,type) (((type *)(ary)->elts)[i]) The usage of such macro is as follows: APR_ARRAY_IDX (new_entries, i, const char *); How can I translate the "type" ?

You can't. This is more like trying to do generics with macro's on C level. And since FPC macro's afaik have no parameter syntax, this is not possible.

Reply by email

Marco van de Voort
to Milan Marusinec: Hmm, what about (+/-): type_of_elts_entry(type_ptr(integer(ary.elts ) + i *…
Show quoted text 10 lines
Marco van de Voort wrote: > > You can't. This is more like trying to do generics with macro's on C level. > And since FPC macro's afaik have no parameter syntax, this is not possible. > > Hmm, what about (+/-): type_of_elts_entry(type_ptr(integer(ary.elts ) + i * sizeof(type_of_elts_entry ) )^ )

The original had the type as a variable, and casted to it later. That is different.

Reply by email

Milan Marusinec
to Marco van de Voort: You can't. This is more like trying to do generics with macro's on C level. And since FPC…
Marco van de Voort wrote 14 lines
> I've started binding libsvn to FPC, and I have encountered the > following macro that I do not know how to translate: > #define APR_ARRAY_IDX(ary,i,type) (((type *)(ary)->elts)[i]) > > The usage of such macro is as follows: APR_ARRAY_IDX (new_entries, i, > const char *); > > How can I translate the "type" ? > You can't. This is more like trying to do generics with macro's on C level. And since FPC macro's afaik have no parameter syntax, this is not possible.

Hmm, what about (+/-):

type_of_elts_entry(type_ptr(integer(ary.elts ) + i * sizeof(type_of_elts_entry ) )^ )

I've been solving issues like this many times on AggPas and icu4pas projects.

Milano

Reply by email