[fpc-pascal] H2pas tool vs others, C header translation

Marco van de Voort marcov at stack.nl
Mon Aug 21 20:08:30 CEST 2017


In our previous episode, Michael Van Canneyt said:
> > I am looking to convert the GNU MPFR library header files, or hire 
> > someone on a bounty to do it if header translation is not so easy with 
> > h2pas and requires lots of hand work, and close checking.
> 
> I do all header translations with h2pas. Most of the time, I run the code
> first through gcc -E, which will take care of all macro magic. Usually h2pas
> has little trouble with the result.

Before everything I do a couple of substs with an editor, then instead of
gcc -E I use small pascal filterprograms to sort the symbols based on
heuristics.  Usually "clean" defines, structs, function calls and "rest".

The clear files I translate by h2pas, the rest manually or with pascal
programs, and then I stitch them together again. I try to preserve comments
as much as possible.

In the past, with very large headers, I did this restitching
semiautomatically, by inserting marker comments while splitting.

I tried all other headerconvertors, and didn't have a better result.



More information about the fpc-pascal mailing list