[lazarus] About compatibility???

Michael Van Canneyt michael.vancanneyt at wisa.be
Fri Mar 8 07:29:49 EST 2002

On Fri, 8 Mar 2002, Mattias Gaertner wrote:

> On Fri, 8 Mar 2002 09:43:14 +0100 (W. Europe Standard Time)
> Michael Van Canneyt <michael.vancanneyt at wisa.be> wrote:
> > > Since it is impossible to translate any c header file to good pascal code, the current h2pas is the better solution.
> > > I would like to add a h2pas frontend to the IDE, so that using c libraries will become much easier. But before that, h2pas must be improved.
> >
> > What is missing in h2pas ? (except a preprocessor :) )
> :)
> If someone does that, I will write a frontend for it.

It is not that easy. The problem with a preprocessor is
that it destroys all constants and macros.



is lost when you preprocess it. The preprocessor replaces all
occurrentces of these constants with the actual values.

so you need 2 passes:

1 pass which takes care of constants and macros only. (unpreprocessed)
1 pass which takes care of the actual function/procedure definitions.
  This can/should be preprocessed.

Then the two passes must be reconciled...

This is not easy to solve. What is more,
- it depends on some C defines being available or not
  (e.g. various POSIX defines) etc etc etc.
- Sometimes, headers are included which are not available, and which are
  strictly speaking not needed for translation - but they do stop the

Like I said, preprocessing and macroitis is a serious problem...
There is no easy way out.

Adding an (external) preprocessor is not the hard part;
it is maybe 10 lines of code; but the output may/may not be usable.


More information about the Lazarus mailing list