RE: [xml] DEBUG_MEMORY_LOCATION problem



  Impossible to tell for example. Your code may include 
libxml include first 
among a zillion other things.

There is no libxml.h file ?

At any rate, after much searching I found the source of the problem.  In
globals.h there is an "#undef xmlMalloc".  So if globals.h gets included
after xmlmemory.h, the debugging define will be overruled.

The problem is complicated by the protecting blocks which ensure that a
header is only compiled once (like #ifdef __XML_GLOBALS_H).  That makes
it impossible to include "xmlmemory.h" as the last header, because by
that time it has already been included.

Both globals.h and xmlmemory.h are included from a variety of places.
So this code will work:

  #define DEBUG_MEMORY_LOCATION
  #include <libxml/tree.h>  // Includes xmlmemory, but not globals

While this code will not:

  #define DEBUG_MEMORY_LOCATION
  #include <libxml/tree.h>
  #include <libxml/parser.h>  // Includes globals

In the second sample globals.h is parsed, triggering the fatal #undef.  

In order to solve this problem I tried to change the #include sequence.
But putting xmlmemory.h first doesn't work: globals.h will overrule it
at a later time.  Putting it last doesn't work, because it is included
from other headers, still before globals.h.

Possible fixes seem to be:
 - removing the #undef's from globals.h (what are they for?)
 - make xmlmemory.h include globals.h

Are these sane ideas?

Regards,
Wessel




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