C to Pascal translation



Hi there,

I'm still busy with my C to Pascal converter, and it starts working quite well. This is not a question about problems, but a question about solutions ;-)

Assume that you got C code with multiple source and header files, how would you like to translate that into Delphi units?

For mere library imports a single unit can be created, like Windows.pas contains the sum of all declarations in a bunch of related (#included) header files. But when the files also contain code, separate *.pas units should be created from the *.c files. Unfortunately then a number of shared identifiers remain, e.g. type names, which cannot be associated with a specific unit. How would you deal with such definitions? Create a <project-name>.pas unit, into which go all shared definitions? And what about the many declarations from the C standard library, should these go into another libc.pas unit?

It's possible to create an text file, containing all the defined names (imports and exports) of a project. Then this file could be splitted into sections, perhaps like *.ini files with inserted [unitname] headers, so that for each section the according *.pas unit can be created. But obviously that file should be prepared in a way that doesn't require much editing, i.e. an alphabetically sorted list of all names is very useless. Instead user-prepared <unitname>.ini files can be used, containing the names which shall go into the according unit, so that these names can be listed already in the appropriate sections of the automatically created project-specific file. But how can the translator then know, which of these files to use, where to find them?

But perhaps you have better ideas, how to create Delphi units from C files? Any thoughts or suggestions are welcome :-)

DoDi
.