Hi,
In my library, I have several initialize()
and cleanup()
functions, for different modules it depends on.
To make this part more safe to use, I decided to follow the RAII rule and built up an Initializer
template class, that takes two functions as parameters:
// initializer.hpp (include guards omitted)
template <void initialize(), void cleanup()>
class Initializer
{
// Does something, but that's not relevant
};
Now, in my xml.hpp
file I have this:
// xml.hpp (include guards omitted)
namespace xml
{
void initialize();
void cleanup();
typename ::Initializer<&initialize, &cleanup> Initializer;
}
This compiles fine but fails on linking because several files include xml.hpp
and gcc complains that there are multiple definitions for xml::Initializer
.
What can I do to solve this ?