libxml compile errors

Started by Ghost Dancer, November 08, 2024, 10:53:20

Previous topic - Next topic

Ghost Dancer

I'm trying to compile the libxml mod but it gives lots of compile errors like this:

C:/BlitzMax/mod/bah.mod/libxml.mod/glue.cpp:402:55: error: invalid conversion from 'char*' to 'const unsigned char*' [-fpermissive]
  402 |                 BBString * s = bbStringFromUTF8String((char *) text);
      |                                                       ^~~~~~~~~~~~~
      |                                                       |
      |                                                       char*

I'm not sure if this is an issue with the C code or Blitz trying to compile it? My C is even rustier than my Blitzmax  :))  Here's the snippet of code from the .cpp file:

BBString * bbStringFromXmlChar(xmlChar * text) {
if (text) {
BBString * s = bbStringFromUTF8String((char *) text);
xmlFree(text);
return s;
} else {
return &bbEmptyString;
}
}

Derron

#1
Why do you want to use bah.mod/libxml.mod ?

check your NGs mod folder ... there is a "text.mod" (module scope) which contains xml.mod.

https://blitzmax.org/docs/en/api/text/text.xml/
(you also have modules for json and others now).

Instead of "libxml" it now utilizes "mxml" (which is a bit more lightweight).

As it was a drop in replacement for libxml, the API (for you) stays almost the same. So there is still TXmlDoc etc.



PS: that error says you need to update a cast in the C file there - we had this a lot with more recent GCCs. So 

BBString * s = bbStringFromUTF8String((char *) text);
must become
BBString * s = bbStringFromUTF8String((const unsigned char *) text);

bye
Ron

Ghost Dancer

Thanks Ron. I'll give that a try.

I'm recompiling code from old (pre-NG) BlitzMax, and it was using libxml. The program I'm updating is massive and its been years since I originally crated it, which is why I've been posting a lot as I try to get it all working (the program has been working fine for years but does not work on Windows 11).

Derron

I was using libxml too and as usual I am nagging Brucey with a lot of things when I stumble over issues ("slow" loading of xml in my game etc). And thus often things are overhauled or new libs are wrapped. Of course Brucey does also do things without me pushing him into. Whatever floats his boat so to say.

But this means if you did not dive into the deepest of libxml then chances are good that things simply "work".


bye
Ron