0

我想在没有 C++11 的情况下使用该库,但它不会为我编译:(理论上它应该按照文档 @ http://easylogging.muflihun.com:“对于较低版本的 C++(非 C++ 11)、请考虑使用Easylogging++ v8.91。")

错误:#error 此文件需要对 ISO C++ 2011 标准的编译器和库支持。此支持目前是实验性的,必须使用 -std=c++11 或 -std=gnu++11 编译器选项启用。

文件结构:

./Main.cpp ./logger/easylogging++.h

Main.cpp 的内容:

#include "logger/easylogging++.h"
_INITIALIZE_EASYLOGGINGPP
using namespace std;

int main(int argc, char* argv[]) {
LINFO << "This is my first log";
return 0;
}

../src/logger/easylogging++.h:在函数'std::string easyloggingpp::internal::threading::getCurrentThreadId()'中:../src/logger/easylogging++.h:691:16:错误:' std::this_thread' 尚未声明 ss << std::this_thread::get_id();

编译器:gcc 版本 4.8.2(Ubuntu 4.8.2-19ubuntu1),操作系统:Ubuntu 14.04 LTS

4

1 回答 1

0

正如 TC 在解决方案中建议的那样,在 easylogging++.h 顶部更改这部分代码:

#if defined(__GNUC__)
#   define _ELPP_GCC_VERSION (__GNUC__ * 10000 \
                               + __GNUC_MINOR__ * 100 \
                               + __GNUC_PATCHLEVEL__)
#   if defined(__GXX_EXPERIMENTAL_CXX0X__)
#      define _ELPP_CXX0X 1
#   elif (_ELPP_GCC_VERSION >= 40801)
#      define _ELPP_CXX11 1
#   endif // defined(__GXX_EXPERIMENTAL_CXX0X__)
#endif // defined(__GNUC__)

_ELPP_CXX0X将和都更改_ELPP_CXX11为 0 将解决此问题。

于 2016-09-08T02:36:35.797 回答