discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Objective-C++?


From: Michael Saure
Subject: Re: Objective-C++?
Date: Thu, 10 Apr 2003 17:36:25 +0200 CEST

> There ought to be a way to call a C++ member function from straight
> C.
> But is this compiler dependent .. ???
Yes, it is...
>
> Fx:  In the COM object model it's possible to call the interface of
> an object
>       from straight C through accessing it's vtable by hand.
>
>     cppObj->lpVtbl->MemberFunction(cppObj, arg1, arg2);
>
>
> How is something like this possible with ordinary C++ objects.
> Cause backstage in the C++ runtime a similar vtable is present,
No, not necessarily. This is only the case when member function are
declared as 'virtual'. Non-virtual member functions are resolved at
runtime,
ie. they are much more like normal functions.

> but how do we get access to it ....
Usually the vtable address is lower than the address of the object
data,
so you would have to use a negative offset from an object pointer to
address the vtable. The size of this offset will be compiler dependant,
just as the organization of the vtable is.
>
> This would solve most of the problems in current C++ ObjC wrapping.
> cause then we could have C++ ivars in ObjC and call them manually via
> C.

Yes, it certainly would do, but I don't think it would be feasible.
Sorry.

Michael Saure





reply via email to

[Prev in Thread] Current Thread [Next in Thread]