Is it valid to attempt to allocate (via ‘new()’) dynamic memory prior to ‘main()’? I am working on software that has static *’s to class objects, and through some rather nasty macro expansion, these object ptrs attempt to instantiate themselves via the ‘new()’ operator. I am working on Irix 6.2 and the software used to work fine under the Irix O32 ABI. When we ported to the N32 ABI, it started seg faulting and Purify reports IPR/IPW fatal errors throughout these static initializers.
If I understand, you are declaring data outside of any functions something like this:
CData* pData = new CData;In my experience (mostly in Visual C++ for Intel), this works fine. The data is, in fact, allocated, and this line executes before the call to main. I have never run across problems with this. If you are having trouble, it may be specific to the platform you’re porting to.