0

我正在尝试使用 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

似乎是编译器生成的移动函数的问题,但显式删除它也不起作用。

LogMessage(const LogMessage&&) = 删除;

有任何想法吗?

干杯,迈克

4

1 回答 1

1

生成的函数不是 LogMessage(const LogMessage&&) = delete;
但它是:
LogStream::LogStream(google::LogMessage::LogStream &&)。

在内部,它将尝试调用 LogStream 的复制构造函数,因此将 ostream 标记为已删除。
解决方法:
在LogStream类里面声明:
LogStream(const LogStream&) = delete;
LogStream& operator=(const LogStream&) = delete;;

干杯

于 2015-09-08T13:40:21.967 回答