From: Tomek Mrugalski Date: Thu, 15 Aug 2019 16:50:57 +0000 (+0200) Subject: [#625,!485] Conditional explicit initialization done. X-Git-Tag: Kea-1.6.0~41^2~64 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3abda71b1dcf88a4d37b6de1f22b83dbdce7e816;p=thirdparty%2Fkea.git [#625,!485] Conditional explicit initialization done. --- diff --git a/configure.ac b/configure.ac index 9b78585611..0a15f6c48f 100644 --- a/configure.ac +++ b/configure.ac @@ -1030,6 +1030,15 @@ AC_MSG_RESULT([$LOG4CPLUS_VERSION]) CPPFLAGS=$CPPFLAGS_SAVED LIBS=$LIBS_SAVED +AC_MSG_CHECKING([log4cplus explicit initialization (log4cplus/initializer.h)]) +AC_LINK_IFELSE( + [AC_LANG_PROGRAM([#include ], + [log4cplus::Initializer initializer;] + )], + [AC_MSG_RESULT([yes]) + AC_DEFINE(LOG4CPLUS_INITIALIZER_H, [1], [Explicit initialization of log4cplus possible])], + [AC_MSG_RESULT(no)]) + # # Configure Boost header path # diff --git a/src/lib/log/logger_manager.cc b/src/lib/log/logger_manager.cc index 23db9faf16..617acc7f88 100644 --- a/src/lib/log/logger_manager.cc +++ b/src/lib/log/logger_manager.cc @@ -24,13 +24,20 @@ #include #include -#include - using namespace std; +// Older log4cplus versions (1.2.0) don't have the initializer.h header that +// would allow explicit initialization. Newer versions (2.0.4 for sure, possibly +// older as well) have it and it's recommended to use it. We detect whether +// it's present or not and do explicit initalization if possible. +#ifdef LOG4CPLUS_INITIALIZER_H +#include namespace { - log4cplus::Initializer initializer; +} +#endif + +namespace { // Logger used for logging messages within the logging code itself. isc::log::Logger logger("log");