> 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