[fpc-pascal] function returning a record vs paramaters

Marco van de Voort marcov at stack.nl
Mon Jul 11 08:35:58 CEST 2005

> | procedure my_procedure(var a_record: t_my_record);
> |
> | In this case, a simple pointer is passed to my_procedure. This is also
> | the way most C libraries work, passing a pointer to a structure.
> Would a C program be able to call a Pascal SO or DLL file and directly read a
> record from pascal, as a structure in C? i.e. no hassles required (presuming the
> record didn't contain strings of course.. let's just say three integers)

Portability is more between specific compilers than between languages.

If the C compiler can be configured to match whatever recordlayout the Pascal
compiler is using, then it works.

P.s. I'd recommend against using complex types as a parameter result. It is
unoptimal. Unless there is a very good reason to pair them into a record,
I'd simply use multiple var parameters, and use the return value for the success
or failure indicator of the function.

More information about the fpc-pascal mailing list