[fpc-pascal]Linking with C
John Coppens
jcoppens at usa.net
Mon Sep 30 03:24:48 CEST 2002
On Sun, 29 Sep 2002 11:16:54 +0200 (CEST)
Michael.VanCanneyt at Wisa.be wrote:
>
>
> On Sun, 29 Sep 2002, John Coppens wrote:
>
> > Hi all.
> >
> > I was trying to link with a C library, and everything went well till one
> > function popped up that didn't wan't to work. Till I investigated the
> > source library code, and found that it was in fact a macro that referenced
> > fields from a struct.
> >
> > The only solution I found, was to write a few C functions that call the
> > macro, then I link to that C proggie. Hardly elegant... Is there a another
> > solution to this?
>
> No. When we translate C library header files, we rewrite the macros always
> as pascal functions. The h2pas conversion tool takes a shot at this, but
> the translation always needs to be hand-tweaked.
>
> Michael.
Hello Michael.
I wanted to avoid changing the original header files, because this seemed
problematic: if new versions of the header files appear, it would be necessary
to reapply the h2pas or similar step, wouldn't it?
Writing a proper C interface avoids this problem, but means it's necessary
to link with an extra .o file. I wonder if it would be possible to combine
the C-generated .o and the Pascal generated .o into one lib.
Thanks,
John
More information about the fpc-pascal
mailing list