logging-log4cxx-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephen Bartnikowski" <sbartnikow...@barkinglizards.com>
Subject RE: Forward Declaration
Date Fri, 12 Sep 2008 17:16:39 GMT
Somebody correct me if I'm wrong, but I don't think it will. In Test.hpp,
the compiler doesn't know what type LoggerPtr is. Since you're referring to
that type directly rather than by a pointer, the compiler needs to know the
full details. It doesn't know that in reality it's a pointer type defined
elsewhere. If for example, your code instead read:
 
...
class Test {
private:
    static log4cxx::LoggerPtr* _logger;
...
 
then the compiler wouldn't complain.
 
- Stephen


  _____  

From: Jon Dahl [mailto:jdahl1972@yahoo.com] 
Sent: Friday, September 12, 2008 12:01 PM
To: log4cxx-user@logging.apache.org
Subject: Forward Declaration


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?

// Test.hpp
namespace log4cxx {
class LoggerPtr;
}

class Test {
private:
    static log4cxx:LoggerPtr    _logger;

public:
    Test();
};

//Test.cpp

#include <log4cxx/logger.h>

using namespace log4cxx;

LoggerPtr Test::_logger(Logger::getRootLogger());

Test::Test() {
}

// end test.cpp

Thanks,

-jd-




Mime
View raw message