[Lazarus] Parser
Hans-Peter Diettrich
DrDiettrich1 at aol.com
Thu Jul 1 19:30:26 CEST 2010
Florian Klaempfl schrieb:
>> A FP-propriety interface part would be added to the C units to make them
>> create an FP compatible compiled unit, usable in the normal way by
>> Pascal units and by the linker.
>
>
> ... and not fully automatable, so not better than current solutions.
> Even worse, it does not cover the cases which are really a problem like
>
> #define CONFIGURE_THE_HEADER_IN_A_CERTAIN_WAY // simple example are the
> UNICODE define in windows headers
> #include <myheader.h>
>
> Things like this are the really nasty corner cases which make h2pas only
> semi automatic.
This is correct, and also is the most important reason for a tighter
integration of C source code into FPC projects.
> Show me a tool which translates C headers fully automatic in *usable*
> pascal units (test case e.g. glibc and mysql), then we can continue this
> discussion.
Just an idea:
The compiler can create the required (ppu?) files, when compiling a C
module. That file then perfectly reflects all the settings, that
affected the code generation of that module. Only this "header" version
is important for the use of that module, not any other
(mis-configurable) header files.
Likewise the compiler can use the information in the ppu file, instead
of those found in any #include file. There may exist some technical
problems with this solution, because C enforces no correspondence
between header and implementation files, neither by name nor content,
but I think that solutions can be found on a package base.
When a package contains a couple of C files, then a common package
header/ppu file could contain the descriptions of *all* items in that
package, and a list of related header files. Then the compiler can skip
over the listed #include files, and use the precise information in the
ppu file instead. This model only requires the construction of packages
for all used C files, and a one-time compilation of these packages, for
the construction of their ppu files. The compiler or a related tool can
create an dummy Pascal library unit for every such package, for easy
(human readable) use of the C packages in Pascal code.
DoDi
More information about the Lazarus
mailing list