According to Hans Ecke:
Would it be possible to just translate the header files to units and simple compile the program? [...]
Unfortunately not. I thought about planning this for the future, but this would mean that GPC would have to copy multiple inheritance with all its ugly implications from C++; some discussion in this list convinced me that it will be much better to implement "Interfaces" (like in Java) into GPC.
Do the mechanisms of polymorphie, inheritance etc work between a library written in C++ and an unit written in GPC?
They don't.
To work around this, you can write a C-style interface that lives without objects for the C++ library and then make a Pascal Unit use these inter- face functions to implement Pascal objects:
C++:
class foo // the thing we want to use { void bar ( int baz ); }
C:
/* This non-OOP interface we must write because OOP information * does not survive transport through an `.o' or an `.a' file. */ void foo_bar ( struct class_foo *self, int baz ) { /* call the object's method */ }
Pascal:
(* This unit implements a `FooObj' that implements a Pascal *) (* OOP interface for the C++ `foo' class. The implementation *) (* uses a non-OOP function written in C. *)
Type FooPtr = ^Foo;
FooObj = object; cppClass: Pointer; (* holds a pointer to the C++ instance *) Procedure Bar ( Baz: Integer ); end (* FooObj *);
Procedure C_foo_bar ( Self: Pointer; Baz: Integer ); AsmName 'foo_bar';
Procedure FooObj.Bar ( Baz: Integer );
begin (* FooObj.Bar *) C_foo_bar ( cppClass, Baz ); end (* FooObj.Bar *);
BTW, what about writing Pascal libraries that provide the same functionality? I am myself working on such a thing (BO5); the EFLIB library (http://ftp.sunet.se/EFLIB/) is another approach (I do not know whether it supports X11), and I am sure that many readers of this list have their own libraries waiting to be ported to GNU Pascal.
Greetings,
Peter -- Peter Gerwinski, Essen, Germany, free physicist and programmer Maintainer GNU Pascal - http://home.pages.de/~GNU-Pascal/ - 1 Oct 1997 PGP key fingerprint: AC 6C 94 45 BE 28 A4 96 0E CC E9 12 47 25 82 75 Fight the SPAM! - http://maps.vix.com/