我正在尝试使用Visual Studio 2015在Windows上构建Google glog库。添加#include解决Windows上的std :: min问题后,出现以下2个主要错误(重复1次)。
1>c:\glog\glog-0.3.3\src\windows\port.h(117): warning C4005: 'va_copy': macro redefinition
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\stdarg.h(20): note: see previous definition of 'va_copy'
1>c:\glog\glog-0.3.3\src\windows\port.cc(58): error C2084: function 'int snprintf(char *const ,const size_t,const char *const ,...)' already has a body
1> c:\program files (x86)\windows kits\10\include\10.0.10150.0\ucrt\stdio.h(1932): note: see previous definition of 'snprintf'
1> vlog_is_on.cc
1>c:\glog\glog-0.3.3\src\windows\port.h(117): warning C4005: 'va_copy': macro redefinition
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\stdarg.h(20): note: see previous definition of 'va_copy'
1>c:\glog\glog-0.3.3\src\windows\glog\logging.h(1266): error C2280: 'std::basic_ios<char,std::char_traits<char>>::basic_ios(const std::basic_ios<char,std::char_traits<char>> &)': attempting to reference a deleted function
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\ios(189): note: see declaration of 'std::basic_ios<char,std::char_traits<char>>::basic_ios'
1> c:\glog\glog-0.3.3\src\windows\glog\logging.h(1266): note: This diagnostic occurred in the compiler generated function 'google::LogMessage::LogStream::LogStream(google::LogMessage::LogStream &&)'
1> utilities.cc
似乎与编译器生成的move函数有关,但是显式删除它也不起作用。
LogMessage(const LogMessage &&)=删除;
有任何想法吗?
干杯,迈克
最佳答案
生成的函数不是LogMessage(const LogMessage &&)= delete;
但它是:
LogStream :: LogStream(google :: LogMessage :: LogStream &&)。
在内部,它将尝试调用LogStream的副本构造函数,因此将调用标记为已删除的ostream。
解:
在LogStream类中声明:
LogStream(const LogStream&)=删除;
LogStream&operator =(const LogStream&)= delete ;;
干杯