template<typename T>
class C
{
public:
static const int static_member = 0;
};Based on what I have observed, an instantiation of C<T> for any T will not cause C<T>::static_member to be instantiated when the code is compiled into a shared library with GCC. It seems to me that using C<T>::static_member as an rvalue would cause it to be instantiated, but I have not had success in causing that to happen in a way that works for my case (more details on why below). Instead, the initialization of C<T>::static_member has to be done this way:
template<typename T>
class C
{
public:
static const int static_member;
};
typedef C<float> FloatInst;
template<> const int FloatInst::static_member = 0;
The above is a simplified example of what happens with
OSG::StageHandlerMixin<ParentT> (and possibly other similar types). What I
am finding is that the symbols for static members of an instantiation such
as OSG::StageParent (OSG::StageParent::DestroyedFunctorsFieldMask and
friends) are not defined in libOSGEffectGroups.so. As such, I get unresolved
symbol errors when loading the PyOpenSG Python extension module.
The reason that this matters is rather specific to how Boost.Python works. In PyOpenSG, OSG::StageParent::DestroyedFunctorsFieldMask is exposed to Python by giving its address to Boost.Python. If my understanding is correct, requesting the address of a static data member of a class template is handled differently by the compiler than asking for the value of the data member. Requesting the value of the data member does not require the symbol to be in libOSGEffectGroups.so, but requesting the address of it does.
I have attached example code that demonstrates, at a very simple level, the problem that I am encountering. I have tested with GCC 4.2.4 and Visual C++ 9.0 SP1. Visual C++ is able to handle the address-of operation using the first form of static data member initialization, but GCC is not. The second form works for both Visual C++ and GCC.
I have a nagging feeling that this, or something very closely related to it, has been encountered before during earlier PyOpenSG development. If so, then that probably happened nearly two years ago, and I have since forgotten the specific circumstances. My hope is that this can be fixed with a GCC compiler option or something that is similarly non-invasive to the OpenSG code in question. Does anyone have any ideas or suggestions about how this can be resolved?
-Patrick -- Patrick L. Hartling Senior Software Engineer, Priority 5 http://www.priority5.com/ The information transmitted in this communication is intended only for the person or entity to which it is addressed and contains proprietary material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please destroy any copies, contact the sender and delete the material from any computer.
template_static.tar.bz2
Description: BZip2 compressed data
------------------------------------------------------------------------------ Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM) software. With Adobe AIR, Ajax developers can use existing skills and code to build responsive, highly engaging applications that combine the power of local resources and data with the reach of the web. Download the Adobe AIR SDK and Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________ Opensg-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/opensg-users
