Menu

#20 Move boost getThreadId to source file

open
nobody
None
5
2003-10-18
2003-10-18
No

I'm using log4cpp with BoostThreads under linux, cygwin
and native win32 (after manually hacking the
configuration files). However, I get large numbers of
"getThreadId function defined but not used" warnings
because the function body is declared in the header
file. Following the pattern from PThreads and
OmniThreads, would it be possible to move the function
body into a new source file? I have done the following,
which works on all of my target platforms:

1. In threading/BoostThreads.hh remove the function
body and only leave the declaration:

std::string getThreadId();

2. Create a new file BoostThreads.cpp with the contents:

#include <log4cpp/threading/Threading.hh>

#if defined(LOG4CPP_HAVE_THREADING) &&
defined(LOG4CPP_USE_BOOSTTHREADS)

namespace log4cpp {
namespace threading {

std::string getThreadId() {
return std::string("not implemented");
};
}
}

#endif // LOG4CPP_HAVE_THREADING &&
LOG4CPP_USE_BOOSTTHREADS

3. Added BoostThreads.cpp to the Makefile / project files.

Discussion


Log in to post a comment.