[fpc-devel]Feedbacks from an industrial code porting experience

Fabio Casamatta casamatta at cesi.it
Thu Mar 1 11:06:02 CET 2001


Dear FPC colleagues,
I'm reporting some experience matured with FPC under Linux, hoping that
it will provide useful hints for fututre development directions.
Recently, as Michael Van Canneyt knows very well (since I have been
helped very much by him), my team has experimented a Linux porting of
the Dynamic Electrical Power Simulator (SICRE,
http://WWW.CESI.IT/services/psa/psw/sicre/index.cfm). The original
software is written for HP-UX 9000 machine, but automatic converter
procedures supplies versions for Digital-OSF (now Compaq-TRU64),
AIX-RS6000 and now partially also for Linux. The code is written in
different languages. The simulation engine (consisting in about 2500
files, more than 50000 lines of code) is written essentially in Apollo
Pascal with something in Fortran and C; the automatic procedures
essentially translate the Apollo Pascal into the Pascals for the other
target machines and in particular for FreePacal in Linux.  The Human
Machine Iterface (some thousands of files, 70000 lines of code) is
written essentially in C++ (plus Motif+X libraries) but links and
includes the Pascal code in order to share database structures. In the
past, above all for the lack of standardisation of Pascal, we examined
the possibility to port all the Pascal code into C code, using some
automatic translator. Problems related to the readability of the
translated code and to the lack of reliable automatic Pascal2C
translators discouraged us to do this. Essentially today we consider the
Pascal code as a "elite" code (even if Pascal is a very good language,
much better then C) to be linked as a library with other C/C++ codes
that can guarantee standardisation. But to make this kind of use, Pascal
compilers should provide code very open and flexible. In particular we
experimented difficulty in solving some problems caused by the
constraints today imposed by FreePascal. As Michael knows, as far as
today some of this problems remain unresolved. In order to provide a
useful feedback from a very fruitful experience (and obviously hoping in
your future considerations of such issues) I tried to make a list of the
major difficulties:
- C (using gcc) main programs including (linking) Pascal code. The
problem is that it is not possible to use a FPC object file (or library)
into a C-main program (problems related to initialization/finalization
of units, even if we didn't use any and code including "writeln"). This
problem has been solved in a non elegant way, simply supplying a
Pascal-shell program using the (ex) main of C. It worked. The engine of
the simulator works under Linux and we are happy.
- C++ (using g++) main programs including (linking) Pascal code. Same
thing that C, even if there is the additional problem (for some target
machine, like HPUX) to provide a call to a C++ initialisation function
(called "_main") for C++ objects (constructors/destructors). It seems
not to work properly in some cases, anyway. Till now, the porting of the
HMI is not working and this is a big problem for us.
- Fortran (using g77) main programs including (linking) Pascal code. We
didn't use, till now.
- linking stage. One of the most important things for an open code is
the possibility to use standard linkers (such as ld) in order to provide
the executable linking together object files from different language in
a very standard and controllable way. The compilers should provide all
the necessary libraries in order to create autonomous object files and
not requiring the use of their own linker for this stage.
I can add that for us any modification on the code in Pascal should be
replicated and verified on the other three platforms, hoping that they
all are compatible for the modifications (obviously it would not happen
if FPC works also on the other three platforms)

After having said so much, I should say again a big "thank you", since I
experimented a very helpful and exciting FPC environment, from a
technical and a human viewpoint. A special thank to Michael who
constantly and promptly helped me during these months.

Fabio Casamatta

Via Rubattino, 54
20134 Milano - Italy
Ph. +39 02 2125 5761
Fax +39 02 2125 5579






More information about the fpc-devel mailing list