【原】error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'std::string'
今天遇到一个非常难以排查的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'的更多相关文章
- (转+原)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) ...
- 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 ...
- uafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new(unsigned int)"解决办法
如果在编译MFC程序的时候出现下列及类似的错误: 1>uafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator ...
- MFC程序出现uafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new(unsigned int)解决办法
在同一个地方摔倒两次之后,决定记录下来这个东西. 问题 1>uafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl opera ...
- 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 ...
- 【QT】error: macro "SIGNAL" passed 3 arguments, but takes just 1
error: macro "SIGNAL" passed 3 arguments, but takes just 1 错误原因: "SIGNAL"后面括号掉了. ...
- [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 ...
- 错误 C2679二进制“没有找到接受“std::string”类型的右操作数的运算符(或没有可接受的转换
错误 C2679二进制“没有找到接受“std::string”类型的右操作数的运算符(或没有可接受的转换 严重性 代码 说明 项目 文件 行 禁止显示状态错误 C2679 二进制“<<”: ...
- [原]error LNK2005:"XXX已经在 XXX.obj 中定义 使用 /FORCE(强制文件输出)暴力解决
参考:https://blog.csdn.net/LG1259156776/article/details/80828720 https://blog.csdn.net/cai18381306175/ ...
随机推荐
- WWDC2015 结束.新一波更新以及bug即将来袭.
WWDC结束.新一波更新以及bug即将来袭. HTTPS 将成为标准链接. http被报错. GamePlayKit 这是搞那样. 还有ReplayKit 那些什么录像分享什么的还有活路么? Mod ...
- ruby -- 进阶学习(六) devise修改邮件发送者邮箱
在config/environment.rb/development.rb或者config/environment/production.rb中, 简单示范例子: Text03::Applicatio ...
- DateTimePicker 控件的格式设置
DateTimePicker 控件的格式设置 CustomFormat属性设置 : yyyy-MM-dd HH:mm:ss 月大写M,分钟小写m,小时H代表24小时计算,h代表12小时计算yyyy- ...
- 伸展树(三)之 Java的实现
概要 前面分别通过C和C++实现了伸展树,本章给出伸展树的Java版本.基本算法和原理都与前两章一样.1. 伸展树的介绍2. 伸展树的Java实现(完整源码)3. 伸展树的Java测试程序 转载请注明 ...
- 小printf的故事(未完待续)
小printf的故事 这篇文章的原文来自:英文原文作者仿照<小王子>中的情节,生动有趣的阐述了小printf从编程小白到专家的成长历程.这是我第一次尝试翻译文章,肯定有很多不足之处,情不要 ...
- IE11之F12 Developer Tools--概述篇
打开Developer Tools的方法: a. 点击F12 b. 在浏览器中选择Tools-->F12 Develooper Tools 打开后图示: 从上图我们可以看到,Developer ...
- [Tool] PLSQL使用技巧
1.PL/SQL Developer保存自定义界面布局 Tools->Preferences->User Interface->Options->Autosave deskto ...
- [Tool] Visual Studio必备插件 + 技能
总结自己常用的VS插件,其中部分需要注册. 在该链接http://www.cnblogs.com/neverc/p/4591501.html中提供 1.Web Essentials(测试支持2010, ...
- DFS --- HNU 13307 Galaxy collision
Galaxy collision Problem's Link Mean: 给定二维坐标平面内的n个整数点,让你把这n个点划分为两个集合,同一集合内的所有点必须两两距离大于5,求这两个集合的元素个数之 ...
- C#中得到两个数百分比 (转)
//此方法得到的百分比后小数太多,不行double percent=Convert.ToDouble(2)/Convert.ToDouble(34); string result=(percent*1 ...