我在VS2008中有一个dll项目,这导致我的应用程序引发访问冲突。我调试后发现,在Log4cxx行的LOG4CXX_DEBUG(logger,myMessage << doubleA << double B);
中,运算符
我尝试在Log4cxx
命名空间中覆盖它:
namespace log4cxx { namespace helpers {
ostream& operator<<(ostream& os,const double& a);
} }
无法编译:
more than one operator "<<" matches these operands:
function "log4cxx::helpers::operator<<(std::ostream &os,const double &a)"
function "std::basic_ostream<_Elem,_Traits>::operator<<(double _Val) [with _Elem=char,_Traits=std::char_traits<char>]"
operand types are: std::basic_ostream<char,std::char_traits<char>> << const double
我尝试在Std名称空间中覆盖它(我不建议这样做):
namespace std {
ostream& operator<<(ostream& os,const double& a);
}
抛出:
more than one operator "<<" matches these operands:
function "std::operator<<(std::ostream &os,std::char_traits<char>> << const double
有什么主意,我该如何适当地使操作员超载并使之工作?
我尝试的另一件事是:我尝试在到达记录器行之前构建消息字符串。
string myMessage = "myMessage" + double A + doubleB;
,然后将此字符串用作LOG4CXX_DEBUG(logger,myMessage);
不会执行任何操作。遇到相同的访问冲突。我尝试过...
std::ostringstream os;
os << "myMessage here << doubleX<< ",valuey=" << doubleY;
LOG4CXX_DEBUG(logger,os.str());
这里也有相同的访问冲突。我也设法用VS2008构建log4cxx
,以为这可能是问题所在,因为我一直在使用VS2005所构建的版本。
您能在这里帮忙吗?我还可以做些什么来做这项工作?