CppLint Cast Char* Error

307 Views Asked by At

I Have got this error on CppLint :

Using C-style cast.  Use reinterpret_cast<xmlChar *>(...) instead  [readability/casting] [4]

When i try to cast something like this :

xmlChar* something = (xmlChar*) anOtherThing;

But if i do :

xmlChar* something = reinterpret_cast<xmlChar *>(anOtherThing);

I have this error on build:

error: reinterpret_cast from type ‘const char*’ to type ‘xmlChar*’ casts away constness

Could you help me please ?

1

There are 1 best solutions below

0
On BEST ANSWER

So the solution is to replace xmlChar* with const xmlChar* like Vivick said.

But if we use xmlChar* like me we can use the function xmlChartStrdup() instead reinterpret() and it avoids to change all codes to put const.

Thanks all