Search code examples
c++charcpplint

CppLint Cast Char* Error


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 ?


Solution

  • 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