So, what you did was this:
1. Left the xpcom DLLs as is (xpcom.dll, nsprr.dll ...) i.e. as built by MSVC
2. Created an import library from the xpcom libraries using BCB's implib. But as you said, this would create a problem for C++ exports
3. Rebuilt the xpcomglue.lib using BCB and a bunch of #defines and linker settings
4. Used your BCB xpcom client alongside the BCB built xpcomglue.


After the above changes, were you able to get your client working with xpcom. And as Christian mentioned, since NSPR is a C library, using functions from NSPR (in the xpcomglue) would not require too much of an effort. Modifying the header files (for the calling conventions) would mean that the binary compatibility (between the various versions) is broken.

May be you can ask the folks from Moz foundation if they would be willing to ship a BCB version of the xpcomglue or if they would let you create one. I currently don't have BCB installed, but I can provide any assistance that you want if you want to build a BCB version.

-- Gangadhar

FFoxGuy wrote:
Let me first state what I understood: You would want to use a xpcom
client built using BCB6 alongside the xpcom library which is built using
MSVC.


Correct


From http://www.mozilla.org/projects/xpcom/glue/Component_Reuse.html,
did you define XPCOM_GLUE in the build ?


Yes


Can you please provide the error listing when you try to link with the
xpcomglue.lib and nspr.lib.


Like I said before, BCB cannot link with MSVC-built import libraries
(e.g.,
xpcomglue.lib and nspr.lib) because the Microsoft's COFF format is
incompatible with Borland's OMF format. If you want to use MSVC-built
DLLs
in BCB project you have to use the "implib" tool to create Borlandish
import
libraries. Obviously this way you can use only free functions (not C++
class
methods, not to mention templates, because of different name mangling
schemes and other things as well).

What I am trying to do now:
1. Leave xpcom.dll,nspr4.dll,plc4.dll,plds4.dll unmodified (use them
exactly
as they were built by MSVC)
2. Create import libs for nspr4.dll,plc4.dll,plds4.dll
as follows "implib -a bcbLibrary.lib Library.dll"
3. Build Glue library using BCB.

In other words, my BCB C++ client will use "standard"
xpcom.dll,nspr4.dll,plc4.dll,plds4.dll built using MSVC.
But Mozilla's Glue library will be compiled by BCB itself.

Unfortunately this approach has its own problems:
for example nsXPCOMGlue.cpp contains a call to the following function:
PR_LoadLibraryWithFlags(PRLibSpec libSpec, PRIntn flags)
Calling this function from BCB's glue code is problematic (even if
calling
convention is the same) because BCB and MSVC may have different ideas
about
what PRLibSpec is. For example sizeof(PRLibSpec) may return different
values
in BCB and in MSVC.

I may need to modify NSPR to export the functions used in the Glue
library
in a compatible way (e.g., using only C++ fundamental types as
function's
arguments and return values) or to change C++ compiler settings to
make sure
that NSPR POD structs are binary compatible between BCB  and MSVC.


I doubt if you can directly use a xpcomglue
built using VC with BCB. Someone correct me if I am wrong.


I've managed to get rid of compile time errors
after I defined the following macros when building the Glue static
library
in BCB.

HAVE_CPP_MODERN_SPECIALIZE_TEMPLATE_SYNTAX
HAVE_CPP_EXPLICIT
HAVE_CPP_TYPENAME
HAVE_CPP_PARTIAL_SPECIALIZATION
HAVE_CPP_2BYTE_WCHAR_T
HAVE_CPP_EXPLICIT
HAVE_CPP_TYPENAME
HAVE_CPP_BOOL
HAVE_CPP_NAMESPACE_STD
HAVE_CPP_UNAMBIGUOUS_STD_NOTEQUAL
XPCOM_GLUE=1
MOZILLA_STRICT_API=1
XP_WIN=1
XP_WIN32=1

I also needed to add a couple of extra #include-s and fix what I
believe
is a bug.

Namely I changed the declaration of AddRef and Release in the
"nsDerivedSafe<T>" class in "nsCOMPtr.h"

Old declaration:
nsrefcnt AddRef(void);//in BCB it defaults to __fastcall calling
convention
nsrefcnt Release(void);// while the calling convention should be
_stdcall

New declaration:
NS_IMETHOD_(nsrefcnt) AddRef(void);
NS_IMETHOD_(nsrefcnt) Release(void);

Reason: overriden virtual functions must have the same calling
convention as
the virtual functions in the base class.
_______________________________________________
Mozilla-xpcom mailing list
[EMAIL PROTECTED]
http://mail.mozilla.org/listinfo/mozilla-xpcom

Reply via email to