Discussion:
Calling C++ shared libraries?
(too old to reply)
Erik Hentell
2004-05-22 05:06:01 UTC
Permalink
Just out of curiousity...

Calling a C shared library in Mops seems straightforward enough, but I
was wondering about calling a C++ shared library. I haven't actually
tried it yet, but the question was burning a hole in my mind so I
thought I'd ask. What do you need to think about in order to
instantiate a class from an OO shared library? (C++ in particular
since C and C++ are so prevalent) Do you simply create a series of
equivalent classes in Mops, or do you just call the member functions
of a class as if it were a C library?

Just curious,
Erik
Mike Hore
2004-05-26 04:13:54 UTC
Permalink
Post by Erik Hentell
...
What do you need to think about in order to
instantiate a class from an OO shared library? (C++ in particular
since C and C++ are so prevalent) Do you simply create a series of
equivalent classes in Mops, or do you just call the member functions
of a class as if it were a C library?
Hi Erik,

Just off the top of my head, the calling conventions on the
PowerPC are standard for all languages, so there's no problem
there, and there wouldn't be a problem if your member function
isn't virtual. But if it's virtual, you'd have to know which
actual code you're going to call. I have an idea that C++
compilers "mangle" their virtual function names for the sake
of the linker, so the name of the class is included, but I
don't know the details. I guess if you could find what the
mangled name of the function is that you want to call, you
could simply call it. But also, the address of self (whoops,
I mean "this") would need to be passed -- is it the first
parameter? I don't know, but someone else might.

Cheers, Mike.

----------------------------------------------------------------
Mike Hore ***@OVE.invalid.icasolution.com.au
----------------------------------------------------------------

Loading...