From: Thomas Geymayer Date: Wed, 4 Jun 2014 00:45:52 +0000 (+0200) Subject: Trying to fix problems retrieving static member address with old compilers. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=746fa419ed591677f1d0e5d43d5c3e5d6069722e;p=simgear.git Trying to fix problems retrieving static member address with old compilers. --- diff --git a/simgear/nasal/cppbind/Ghost.hxx b/simgear/nasal/cppbind/Ghost.hxx index 42077e18..f16ea20c 100644 --- a/simgear/nasal/cppbind/Ghost.hxx +++ b/simgear/nasal/cppbind/Ghost.hxx @@ -58,6 +58,18 @@ inline T* get_pointer(osg::observer_ptr const& p) return ref.get(); } +// Both ways of retrieving the address of a static member function +// should be legal but not all compilers know this. +// g++-4.4.7+ has been tested to work with both versions +#if defined(SG_GCC_VERSION) && SG_GCC_VERSION < 40407 + // The old version of g++ used on Jenkins (16.11.2012) only compiles + // this version. +# define SG_GET_TEMPLATE_MEMBER(type, member) &member +#else + // VS (2008, 2010, ... ?) only allow this version. +# define SG_GET_TEMPLATE_MEMBER(type, member) &type::member +#endif + /** * Bindings between C++ and the Nasal scripting language */ @@ -396,20 +408,9 @@ namespace nasal )); BaseGhost* base = BaseGhost::getSingletonPtr(); - base->addDerived - ( + base->addDerived( this, - // Both ways of retrieving the address of a static member function - // should be legal but not all compilers know this. - // g++-4.4.7+ has been tested to work with both versions -#if defined(SG_GCC_VERSION) && SG_GCC_VERSION < 40407 - // The old version of g++ used on Jenkins (16.11.2012) only compiles - // this version. - &getTypeFor -#else - // VS (2008, 2010, ... ?) only allow this version. - &Ghost::getTypeFor -#endif + SG_GET_TEMPLATE_MEMBER(Ghost, getTypeFor) ); // Replace any getter that is not available in the current class. @@ -1155,17 +1156,25 @@ namespace nasal &_ghost_type_strong, supports_weak_ref::value ? &_ghost_type_weak : NULL ) { - _ghost_type_strong.destroy = &destroy; + _ghost_type_strong.destroy = + SG_GET_TEMPLATE_MEMBER(Ghost, destroy); _ghost_type_strong.name = _name_strong.c_str(); - _ghost_type_strong.get_member = &getMember; - _ghost_type_strong.set_member = &setMember; + _ghost_type_strong.get_member = + SG_GET_TEMPLATE_MEMBER(Ghost, getMember); + _ghost_type_strong.set_member = + SG_GET_TEMPLATE_MEMBER(Ghost, setMember); - _ghost_type_weak.destroy = &destroy; + _ghost_type_weak.destroy = + SG_GET_TEMPLATE_MEMBER(Ghost, destroy); _ghost_type_weak.name = _name_weak.c_str(); bool can_weak = supports_weak_ref::value; - _ghost_type_weak.get_member = can_weak ? &getMember : 0; - _ghost_type_weak.set_member = can_weak ? &setMember : 0; + _ghost_type_weak.get_member = can_weak + ? SG_GET_TEMPLATE_MEMBER(Ghost, getMember) + : 0; + _ghost_type_weak.set_member = can_weak + ? SG_GET_TEMPLATE_MEMBER(Ghost, setMember) + : 0; } static GhostPtr& getSingletonHolder()