Re: [xml] Creating Win32 wrapper function for exported variables



On Tue, Jul 17, 2001 at 10:19:15AM -0600, Vakoc, Mark wrote:

In Win32 you can import only functions from a library (.DLL) and not
variables.  This causes problems if libxml2 is built as a dll, and a program
attempts to use an exported variable.  It will compile/link, but will fail
at runtime.

I propose creating simple wrappers for global parsing variables.  A good
example program is xsltproc, which has a line

if (novalid == 0)
  xmlLoadExtDtdDefaultValue = 6;
else
  xmlLoadExtDtdDefaultValue = 0;

If xsltproc is linked against libxml2 as a .DLL (not as a .lib), this will
cause a segv.

I created a wrapper function in parserInternals so the code now looks like

if (novalid == 0)
  xmlSetLoadExtDtdDefaultValue(6);
else
  xmlSetLoadExtDtdDefaultValue(0);

Extremely simple, but saves us win32 programmers some troubles. (I also have
a xmlGetLoadExtDtdDefaultValue wrapper).

What do you think?  

  Fine, send patches, don't forget to add the properly formatted 
documentation comments for the new functions.
  I'm in the process of trying to cleanup the global variable problem,
I didn't know about the Win32 DLL issue, that's an interesting feedback,

  thanks a lot,

Daniel

-- 
Daniel Veillard      | Red Hat Network http://redhat.com/products/network/
veillard redhat com  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
Sep 17-18 2001 Brussels Red Hat TechWorld http://www.redhat-techworld.com




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