Easylogging 8.91 not compling without c++11

1k views Asked by At

I want to use the library without C++11 but it won't compile for me: (Theoretically it should as per documentation @http://easylogging.muflihun.com: "For lower version of C++ (non-C++11), please consider using Easylogging++ v8.91. ")

error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.

File structure:

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

Contents of 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: In function ‘std::string easyloggingpp::internal::threading::getCurrentThreadId()’: ../src/logger/easylogging++.h:691:16: error: ‘std::this_thread’ has not been declared ss << std::this_thread::get_id();

Compiler: gcc version 4.8.2 (Ubuntu 4.8.2-19ubuntu1), OS: Ubuntu 14.04 LTS

1

There are 1 answers

0
Rory Hart On

As T.C. suggested in the solution is to change this section of code at the top of 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__)

Changing both _ELPP_CXX0X and _ELPP_CXX11 to 0 will fix the issue.