RE: [xml] Patches for Win32/MSCC build



Hello.

Hmm... naming decoration makes problems, you say? Weeeeeell......

The current naming decoration places an underscore before every exported
function name in the export list. This is the case when you use a cdecl
calling convention, which we use. You can change the project settings and
use the apropriate compiler switch: /Gz (for stdcall), /Gr (for fastcall) or
/Gd (for cdecl). The one you need would be /Gz (for stdcall), because you do
not have those offending underscores when using it. APIENTRY is a macro and
resolves to __stdcall, which is a MS-specific calling convention declarator.
You do not need to use it, because you can solve everything with the
apropriate compiler switch.

However, I STRONGLY DISCOURAGE you from doing this. I'll try to exlpain why.

Calling conventions influence the prolog and epilog code generated by the
compiler for each function. When calling a cdecl function, the caller is
responsible for cleaning up the stack, say, the calling function pops the
parameters passed to the called function. You know what that meams? That
means that only cdecl functions can do varargs. If you change the calling
conventions to stdcall (the one used by all Win32 API functions), then do
not use variable argument lists, or your program shall either crash, produce
memory leaks, or do both in the respective order. Since libxml2 contains one
function or three with varargs, we cannot change the calling convention and,
unfortunately, the naming decoration rule is bound to the calling
convention.

Rather, try to configure the Borland's C++ buider to use MSCC-generated DLL
with this cdecl calling convention. Chances are good it can do so. Ideally,
you would use the source of libxml2 and try to generate the libxml2.DLL with
Borland's compiler. That would be the best thing.

Ciao
Igor


-----Original Message-----
From: Nilo S. Mismetti [mailto:nilo newpos com]
Sent: Tuesday, April 17, 2001 2:11 PM
To: xml gnome org
Subject: Re: [xml] Patches for Win32/MSCC build


Hi there,

The process to implement the Win32 DLL linkage is correct but 
the generated
DLL cannot be used by other compilers (like the Borland C++ Builder).

The reason is that all functions are exported according the MS name
convention.

One solution could be the usage of the  APIENTRY macro like 
the example:

BOOL APIENTRY xmlWriteDoc(xmlDocPtr doc,LPSTR FileName,int 
CompressLevel);

Comments?

Nilo




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]