Menu

#108 test/SingletonDll/singletondll.cpp error on g++ 4.1.1

closed-rejected
None
5
2006-05-26
2006-05-26
No

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)
}

Discussion

  • Joseph Winston

    Joseph Winston - 2006-05-26

    Logged In: YES
    user_id=398495

    This is for loki-0.1.4

     
  • Peter Kuemmel

    Peter Kuemmel - 2006-05-26

    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

     
  • Peter Kuemmel

    Peter Kuemmel - 2006-05-26
    • assigned_to: nobody --> syntheticpp
    • status: open --> closed-rejected
     

Log in to post a comment.

MongoDB Logo MongoDB