> What I had in mind, is that in source this is a static function, but in
export
> lib (or in DLL itself) it looks like
> nsComponentManager::CreateInstance@SomethingElseCompilerSpecific and this
will
> prevent this DLL/LIB to be linked to code compiled with other compilers.
What
> I had in mind, that register/unregister/unload/classcreate functions
should be
> defined as pure C API, somthing like Microsoft's DllRegisterServer or
> DllGetClassObject. Those functions are exported with that names and they
can
> be used by any compiler.
>
> This means that if mozilla will be compiled with Watcom (for example) this
> mean that my project will have to be made with Watcom too. Or the
opposite -
> if I intend to use Watcom C/C++ compiler as a primary compiler, I won't be
> able to use mozilla with it
>
> --
> --
> Regards,
> Waleri
Ahhh.... I sort of jumped into this thread and missed the point of the
original question. Waleri is correct. Whatever compiler builds xpcom.dll or
libxpcom.so is the same compiler you must use to build and link your XPCOM
type project. The reason is exactly as is stated. The xpcom library exports
the *class* nsComponentManager, and due to non-standardized name mangling,
other languages will not properly link to it.
I agree that the methods which are part of nsComponentManager could be
provided in an extern "C" wrapper. I'm not sure how to go about doing this,
but one simple method would be to provide these same methods but as C
functions (no name mangling) which just used the internal global components
manager to proxy off the calls. No real big loss in efficiency.
The global is located in nsXPComInit.cpp:
// Globals in xpcom
nsComponentManagerImpl* nsComponentManagerImpl::gComponentManager = NULL;
Or perhaps even better would be a "C" function which returned an
nsIComponentManager pointer (this would be the global implementation of
this.) That would be okay, since it would be returning an interface pointer.
Plus it would mean less wrapping of the all the individual component manager
methods. This function would just return the gComponentManager listed above.
Ken