[fpc-pascal] handing over array of pchars to C program
Jonas Maebe
jonas.maebe at elis.ugent.be
Mon Sep 3 09:34:34 CEST 2007
On 03 Sep 2007, at 07:08, Marc Santhoff wrote:
> has anyone managed to build in a pascal program what in C is a
>
> char *strings[]
>
> and use it from C?
>
> In pascal terms this is a single dimensional array aka vector of
> PChar.
>
> Do I have to make copies of any string or is it sufficient to fill
> up an
> array with PChar?
That completely depends on what the Pascal and C programs do with
those pchars afterwards. In general, there's no difference in passing
an array of pchars to a C function compared to passing them to a
Pascal procedure: just make sure they are not freed before their last
use. Only if the C program may free them later, you have to allocate
them using malloc/free (although that's unlikely to be the case).
Jonas
More information about the fpc-pascal
mailing list