error: cannot pass objects of non-trivially-copyable type

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Acoolbest/article/details/50053531

Ubuntu下C++编译出错如下

error: cannot pass objects of non-trivially-copyable type ‘std::string {aka class std::basic_string<char>}’ through ‘...’

   CPublicFunction::WriteLog("%s", ex.displayText());


改动如下:

CPublicFunction::WriteLog("%s", ex.displayText().c_str());

即在要打印的string后面加 .c_str()

编译即可通过~

猜你喜欢

转载自blog.csdn.net/Acoolbest/article/details/50053531