CppLint铸造字符*错误
CppLint Cast Char* Error
我在CppLint:上遇到了这个错误
Using C-style cast. Use reinterpret_cast<xmlChar *>(...) instead [readability/casting] [4]
当我试着投这样的东西时:
xmlChar* something = (xmlChar*) anOtherThing;
但如果我这样做:
xmlChar* something = reinterpret_cast<xmlChar *>(anOtherThing);
我在构建时有这个错误:
error: reinterpret_cast from type ‘const char*’ to type ‘xmlChar*’ casts away constness
你能帮我吗?
所以解决方案是用const xmlChar*替换xmlChar*,就像Vivick说的那样。
但是,如果我们像我一样使用xmlChar*,我们可以使用函数xmlChartStrdup((来代替interpret((,它可以避免更改所有代码以放入const。
感谢所有
相关文章:
- 我的字符计数代码计算错误.为什么
- 错误:字符数组的初始值设定项太多
- 需要帮助在 c++ 中将字符串转换为字符 ----错误 "const char *" 类型的值不能用于初始化 "char" 类型的实体
- 如何解决一元"*"(有"字符")错误的无效类型参数?
- 在函数 strcpy() 中访问字符数组时出现分段错误
- 错误:请求从"常量字符 [5]"转换为非标量类型"字符串"
- 为什么我的代码在尝试复制字符数组时引发 C6386 错误?
- 为什么C++在将浮点数转换为字符时没有显示缩小转换错误?
- C++ 字符错误
- 增量生成 - 错误:字符串的第一个字符应'0'或'1'
- 我如何处理有关输入的字符串大小超过字符数组设置大小的错误?
- C++错误字符分配
- C 字符串对象错误字符
- 奇怪的错误字符加密 (ASCII)
- 将 XOR 加密错误字符转换为 int 会失去精度
- 错误:字符数组的初始化器字符串太长c++
- 文件输出中存在错误字符
- 我使用 POCO 解析 JSON.它抛出一个异常:JSON 异常:错误字符.如何处理汉字
- 返回错误字符的c++数组
- c++凯撒密码程序执行错误字符