logging-log4cxx-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Curt Arnold <carn...@apache.org>
Subject Re: Forward Declaration
Date Fri, 12 Sep 2008 19:23:46 GMT

On Sep 12, 2008, at 12:00 PM, Jon Dahl wrote:

> Hello,
>
> I'm wondering if it is possible to use forward declaration with  
> log4cxx classes in a class header file. I would like to exclude the  
> log4cxx headers files in my header files if possible and include the  
> log4cxx header files in my cpp(source) files.
>
> Should this work?
>

No.  LoggerPtr is a template expansion and you'd need at least the  
template definition incorporate it in a header file.  However, you may  
want to consider not having a LoggerPtr in your class definition at  
all, but just have it in your implementation.  Something like:

myfoo.cpp

#include <log4cxx/logger.h>

//  anonymous namespace, members are visible only in this compilation  
unit
//   like static but better
//
namespace {
log4cxx::LoggerPtr logger(log4cxx::Logger::getRootLogger());
}

void Foo::someFunction() {
     LOG4CXX_INFO(logger, "Hello, World");
}



Mime
View raw message