Re: [xml] Docbook compilation error



On Thu, Nov 20, 2003 at 10:03:12AM +1100, Malcolm Tredinnick wrote:
There is this source file "ext.c" in docbook2x that includes "hash.h", which in turn includes the 
"parser.h" header file.

At attempting to compile, I get the following error:

In file included from hash.h:22,
                 from ext.c:19:
parser.h:265: parse error before "xmlHashTablePtr"

You can define pointers to structures even though the structure
definition is not available. A pointer is the same size, no matter what
it points to. This is a typical way to define an opaque pointer.

  Right,

The error you are seeing does not necessarily come from the libxml2 code

   It may come from some changes in the libxml2 code where 
both parser.h and hash.h depends on each other... 
   hash.h requires xmlChar so it includes parser.h, but parser.h
requires hash.h for the hash tables in the parser context.
the solution is both simple and ugly: export the structure first then
call other includes ...

--------------------------------------------
#ifndef __XML_HASH_H__
#define __XML_HASH_H__
                                                                                
#ifdef __cplusplus
extern "C" {
#endif
                                                                                
/*
 * The hash table.
 */
typedef struct _xmlHashTable xmlHashTable;
typedef xmlHashTable *xmlHashTablePtr;
                                                                                
#ifdef __cplusplus
}
#endif
                                                                                
#include <libxml/xmlversion.h>
#include <libxml/parser.h>
                                                                                
#ifdef __cplusplus
extern "C" {
#endif
--------------------------------------------

   I will commit this in CVS. For the applications the simplest is to 
#include <libxml/parser.h> before #include <libxml/hash.h>

Daniel

-- 
Daniel Veillard      | Red Hat Network https://rhn.redhat.com/
veillard redhat com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/



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