Hello. I'll create a library in Object Pascal. I'll compile it in a DLL/so/dynlib and want to define a public interface to be used in any language so I decided to define it as "C public functions".
I'll use objects so some functions of the library should return or receive object references but I'm not sure which C data type should I use. As example, in pseudo Object Pascal: _______________________________________ LIBRARY theLib; USES unitObject; EXPORT FUNCTION CreateObject: TTheObjectClass; CDECL; EXPORT PROCEDURE UseObject (Obj: TTheObjectClass; Param: INTEGER); CDECL; EXPORT PROCEDURE DestroyObject (Obj: TTheObjectClass); CDECL; END. ________________________________________ And the pseudo C header: ________________________________________ /* theLib.h */ typedef TTheObjectReference void*; extern TTheObjectReference CreateObject (void); pragma __DLL__ ("theLib"); extern void UseObject (TTheObjectReference Obj, long int Param); pragma __DLL__ ("theLib"); extern void DestroyObject (TTheObjectReference Obj); pragma __DLL__ ("theLib"); ________________________________________ Then, in a pseudo C program: ________________________________________ #include "theLib.h" void main (void) { TTheObjectReference Object; Object = CreateObject (); UseObject (Object, 1); DestroyObject (Object); } _________________________________________ Is this correct or should I use a different approach? Thanks. _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal