Greg Larson wrote:
>
> I need to set up a couple of functions in nsISupports derived class.
>
> class myILogger : public nsISupports {
>
> // some xpcom functions that I will access from javascript
>
> };
>
> class myLogger : public myILogger {
>
> // cut out the XPCOM macros here
>
> public:
> static void D( const char* format, ... );
> };
>
> void myLogger::D( const char* format, ... ) {
> // do some stuff with standard static libraries...
> }
>
> Assuming that I didn't mistype anything this compiles fine and
> gets put into libmyLogger.so, myLogger.xpt, etc..
>
> Here is the problem:
>
> From within another XPCOM componant I am trying to make the following
> call:
>
> myLogger::D( "Hello %s\n", "World" );
>
> And that compiles fine too.
>
> When I run the application loads the calling component, I get a loading
> error:
>
> error in loading .... libmyLogger.so: undefined symbol: D__13myLoggerPCce
> which I assume is the mangled name of myLogger::D
>
> How can i provide this functionality under XPCOM? What am I doing wrong
> here?
>
> Thanks.
XPCOM avoids inter-DLL linkage by using interfaces and virtual
calls. You can't do that with static function. Using static
functions bypasses XPCOM and you're on your own.
In the sense that XPCOM interfaces (in C++) are just C++ classes,
you can do anything you want. But compliant XPOM interfaces can
only use a subset of C++ functionality.
Why not implement the method on instances and have the instances
delegate the call to a static method hidden in the
implementation?
John.