error: passing ‘const AppJniCommand’ as ‘this’ argument discards qualifiers [-fpermissive]

Posted 柳鲲鹏

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了error: passing ‘const AppJniCommand’ as ‘this’ argument discards qualifiers [-fpermissive]相关的知识,希望对你有一定的参考价值。

具体错误:

proxy_jni_function.cpp:199:55: error: passing ‘const AppJniCommand’ as ‘this’ argument discards qualifiers [-fpermissive]
  199 |     jbyte* jdata = pJniCommand->jstringToJbyte(jresult);
      |                                                       ^

错误是奇怪的,原因是简单的,就是多了个const:

static void jstringToJson(jstring jresult, const AppJniCommand* pJniCommand)
{
    jbyte* jdata = pJniCommand->jstringToJbyte(jresult);
}

改成:

static void jstringToJson(jstring jresult, AppJniCommand* pJniCommand)

以上是关于error: passing ‘const AppJniCommand’ as ‘this’ argument discards qualifiers [-fpermissive]的主要内容,如果未能解决你的问题,请参考以下文章

QT & C++:传递 'const QString' 丢弃限定符

报错const passing as ‘this‘ argument discards qualifiers [-fpermissive]的

值传递(pass-by-value)引用传递(pass-by-reference)以及函数与const关系

effective_c++条款20,用pass-by-reference-to-const替换pass-by-value

Effective C++条款20:宁以pass-by-reference-to-const替换pass-by-value。Test code

variadic templates & pass by const reference & member operator [] in const map & gcc suc