今天遇到一个非常难以排查的BUG,谷歌度娘都问过了依旧无解,最后自己重新尝试之后找到解决方案:

先看一下报错信息:

1>.\lenz.cpp(2197)  error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion)
1> D:\Program Files\VC\include\ostream(650): could be 'std::basic_ostream<_Elem,_Traits> &std::operator <<<wchar_t,std::char_traits<wchar_t>>(std::basic_ostream<_Elem,_Traits> &,const char *)'
1> with
1> [
1> _Elem=wchar_t,
1> _Traits=std::char_traits<wchar_t>
1> ]
1> D:\Program Files\VC\include\ostream(697): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<wchar_t,std::char_traits<wchar_t>>(std::basic_ostream<_Elem,_Traits> &,char)'
1> with
1> [
1> _Elem=wchar_t,
1> _Traits=std::char_traits<wchar_t>
1> ]
......//一行出错后就会有一堆这样的With[]....出现,非常烦

网上搜了一下,很多人说是因为没有#include <string>的缘故,但是反复确认后发现我有做到。百思不得其解,还一度以为是不同文件的头文件重复引用导致<string>失效,但是这条说不通!后面冷静了之后,双击错误信息查看源码,发现基本上这些错误含有两个特征:

1.都是LOG4CPLUS_DEBUG等调试函数

2.参数都有string类型

然后我单独写了一小段程序验证了一下,好家伙,真是这样子。原来,LOG4CPLUS_DEBUG函数不能直接打印string对象,只支持其转换形式.c_str()。

解决方法:把所有的LOG4CPLUS_DEBUG函数中的string加个c_str()

【原】error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'std::string'的更多相关文章

  1. (转+原)VC编译错误:uafxcw.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) 已经在 LIBCMT.lib(new.obj) 中定义

    参考网址:http://zhanyonhu.blog.163.com/blog/static/16186044201023094754832/ 1>uafxcw.lib(afxmem.obj) ...

  2. Solve Error: nafxcw.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new[](unsigned int)" (??_U@YAPAXI@Z) already defined in libcpmt.lib(newaop.obj)

    Error: nafxcw.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new[](unsigned int)&quo ...

  3. uafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new(unsigned int)"解决办法

    如果在编译MFC程序的时候出现下列及类似的错误: 1>uafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator ...

  4. MFC程序出现uafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new(unsigned int)解决办法

    在同一个地方摔倒两次之后,决定记录下来这个东西. 问题 1>uafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl opera ...

  5. Dubbo管理平台搭建(duboo-admin-2.5.4)遇到的问题:org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'uriBrokerService': Cannot create inner bean '(inner bean)' of type

    1.将dubbo的war包方式tomcat的webapps文件夹下,启动tomcat报错 错误信息如下: ERROR context.ContextLoader - Context initializ ...

  6. 【QT】error: macro "SIGNAL" passed 3 arguments, but takes just 1

    error: macro "SIGNAL" passed 3 arguments, but takes just 1 错误原因: "SIGNAL"后面括号掉了. ...

  7. [ERROR ] Error parsing configuration file: /etc/salt/minion - conf should be a document, not <type 'str'>.

    错误信息 [ERROR ] Error parsing configuration file: /etc/salt/minion - conf should be a document, not &l ...

  8. 错误 C2679二进制“没有找到接受“std::string”类型的右操作数的运算符(或没有可接受的转换

    错误 C2679二进制“没有找到接受“std::string”类型的右操作数的运算符(或没有可接受的转换 严重性 代码 说明 项目 文件 行 禁止显示状态错误 C2679 二进制“<<”: ...

  9. [原]error LNK2005:"XXX已经在 XXX.obj 中定义 使用 /FORCE(强制文件输出)暴力解决

    参考:https://blog.csdn.net/LG1259156776/article/details/80828720 https://blog.csdn.net/cai18381306175/ ...

随机推荐

  1. GET方法传递中文参数乱码解决办法

    1.在页面中对你的URL进行编码 使用------encodeURI(你要使用的中文参数值)如:...?username"+encodeURI(“小甜甜") 2.在后台通过解码来接 ...

  2. Android性能优化之内存篇

    下面是内存篇章的学习笔记,部分内容与前面的性能优化典范有重合,欢迎大家一起学习交流! 1)Memory, GC, and Performance 众所周知,与C/C++需要通过手动编码来申请以及释放内 ...

  3. python面试题大全(一)

    注:本面试题来源于网络,转载请注明来自http://www.cnblogs.com/goodhacker/p/3366618.html. 1. (1)python下多线程的限制以及多进程中传递参数的方 ...

  4. 高效查看MySQL帮助文档的方法

    在mysql的使用过程中, 可能经常会遇到以下问题: 某个操作语法忘记了, 如何快速查找? 如何快速知道当前版本上某个字段类型的取值范围? 当前版本都支持哪些函数?希望有例子说明.. 当前版本是否支持 ...

  5. 用emacs的org2blog组件写cnblogs博客 -- 环境配置及使用

    Table of Contents 配置 使用 创建一篇博文并发布 更新一篇博文 删除一篇博文 待办 本文给出了一个安装.配置org2blog的方法,实现在emacs中书写blog文章.并发布到cnb ...

  6. ASP.NETC#通用扩展函数之TypeParse 类型转换方便多了

    用法: var int1 = "2".TryToInt();//转换为int失败返回0 var int2 = "2x".TryToInt(); var int3 ...

  7. Qt Style Sheet实践(一):按钮及关联菜单

    导读 正如web前端开发中CSS(Cascade Style Sheet)的作用一样,Qt开发中也可以使用修改版的QSS将逻辑业务和用户界面进行隔离.这样,美工设计人员和逻辑实现者可以各司其职而不受干 ...

  8. 数论 - 高精度Fibonacci数 --- UVa 10183 : How Many Fibs ?

    How many Fibs? Description Recall the definition of the Fibonacci numbers: f1 := 1 f2 := 2 fn := f n ...

  9. 【EF 译文系列】重试执行策略的局限性(EF 版本至少为 6)

    原文链接:Limitations with Retrying Execution Strategies (EF6 onwards) 当使用重试执行策略的时候,大体有以下两种局限性: 不支持以流的方式进 ...

  10. 设计模式--简单工厂(Factory)模式

    温故而知新,看了以前写的博文<Asp.net读取Excel文件 2>http://www.cnblogs.com/insus/archive/2011/05/05/2037808.html ...