The .o files produced by GPC are in the same format as those of all other GNU compilers, so there is no problem in writing libraries for other languages in Pascal. To use them, you will need to write kind of interface – a header file in C. However there are some things to take into account, especially if your Pascal unit exports objects:
procedure FooBAR; attribute (name = 'FooBAR'); begin WriteLn ('FooBAR') end;
This one can be imported from C with extern void FooBar().
type VMT = record ObjectSize: PtrInt; { Size of object in bytes } NegObjectSize: PtrInt; { Negated size } Methods: array [1 .. n] of procedure; { Pointers to the virtual methods. The entries are of the repective procedure or function types. } end;
You can call a virtual method of an object from C if you explicitly declare this struct and explicitly dereference the Fun array. The VMT of an object FooBAR is an external (in C sense) variable vmt_Foobar internally.