singletondll.cpp fails to compile on g++ 4.1.1 with the
following error:
$ make -k CXX=g++-4.1.1
g++-4.1.1 --shared -Wall -Wold-style-cast -Wundef
-Wsign-compare -Wconversion -Wpointer-arith -pedantic
-O2 -I../../include -DNDEBUG -o libsingletondll.so
singletondll.cpp -L. -lfoo
singletondll.cpp:22: error: specialization of 'static
T& Loki::Singleton<T>::Instance() [with T = Foo]' in
different namespace
singletondll.cpp:22: error: from definition of
'static T& Loki::Singleton<T>::Instance() [with T = Foo]'
A simple fix for this problem is to change:
LOKI_SINGLETON_INSTANCE_DEFINITION(FooSingleton)
to:
namespace Loki // jbw: Needed for gcc
4.1.1
{
LOKI_SINGLETON_INSTANCE_DEFINITION(FooSingleton)
}
Logged In: YES
user_id=398495
This is for loki-0.1.4
Logged In: YES
user_id=1159765
Thanks for the report Joseph,
this bug is already fixed in cvs:
loki/Singleton.h:
#define LOKI_SINGLETON_INSTANCE_DEFINITION(SHOLDER)\
namespace Loki\
{\
template<>\
SHOLDER::ObjectType&
Singleton<SHOLDER::ObjectType>::Instance()\
{\
return SHOLDER::Instance();\
}\
}
Peter