Re: [xml] xmlChar double ptr
- From: david hagood gmail com
- To: j s bach o2online de
- Cc: xml gnome org
- Subject: Re: [xml] xmlChar double ptr
- Date: Tue, 6 May 2008 09:08:46 -0500 (CDT)
Hei,
how do i define a double ptr xmlChar? is it possible at all?
static xmlChar* mapper[] = {"bla", "blubber"} ;
doesn't work. g++ says
XMLStructure.h:75: error: invalid conversion from ?const char*? to
?xmlChar*?
There's 2 problems here:
One is that, under many configurations of g++, quoted strings are of type
"const char []", which will coerce to "const char *". Since you are
assigning them to a non-const pointer, this is a const-ness violation.
Changing your variable to "const xmlChar *" (or better still "const
xmlChar * const") would help this.
(BTW: in C++ "const" implies "static". Also, making the array of pointers
itself constant is good practice, hence my recommendation of "const
xmlChar * const")
The second is that "xmlChar" is actually "unsigned char", so you are again
crossing a type, and that will ALSO be an error.
The best way around this would be to cast the strings, thus:
const xmlChar *const mapper[] =
{
reinterpret_cast<const xmlChar *>("bla"),
reinterpret_cast<const xmlChar *>("blubber")
};
You could also use the libxml2 "BAD_CAST" macro:
const xmlChar *const mapper[] =
{
BAD_CAST "bla",
BAD_CAST "blubber"
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]