1

I read the souce code of log4cplus-1.1.2 recently, and found that SharedLoggerImplPtr seem to be the better type for Loger::value than spi::LoggerImpl *

The definition of Loger::value in logger.h at line 284-285:

/** This is a pointer to the implementation class. */
spi::LoggerImpl * value;

The implementation of ctor and dtor in logger.cxx at line 105-110, 149-153:

Logger::Logger (spi::LoggerImpl * ptr)
    : value (ptr)
{
    if (value)
        value->addReference (); 
}

Logger::~Logger ()
{
    if (value)
        value->removeReference ();
}

Is that true?

sfzhang
  • 669
  • 9
  • 18

1 Answers1

1

I vaguely remember that this was because of template instantiation exports issues on Windows. Basically, Visual Studio would complain that while Logger is exported, SharedPtr<LoggerImpl> is not exported. But marking whole template for export has other consequences and issues.

wilx
  • 17,697
  • 6
  • 59
  • 114
  • Thank you very much! Yes, both template `SharedObjectPtr` and the instantiated `SharedPtr` are not exported. – sfzhang Aug 16 '14 at 01:36