C++ Static Link Lib pointer problem!!

Started by
0 comments, last by Wavesonics 17 years, 4 months ago
I have 36 hours to finish my semester long project and I have a ton more to do. And A little while ago i decided to split it up into 4 "projects". 3 of which compile down to static link libs, then the last links to the 3 libs and runs the main ect. All compiles now. And runs, BUT!!!! I have a class that I instantiate in the constructor of 1 of the classes in a static link lib (SLL from now on) and that class has member varriables that are set in the constructor. I print them out at the end of the constructor and its all good. But then in a subsequent function call to that class I attempt to use these member varriables and their addresses have changed! They're all efed! Even non-pointer vars like a simple int m_i; If i try to print it or use it some where or ANYTHING it crashes the prog. I've printed the addresses and they are definately changed. This code worked 100% b4 I put it into a SLL and I havent changed anything about it. This is the function call that actually crashes it, here it crashes just after printing "Test: " when it tries to use the int var 'test'

void AutonomousActionService::processAutonomousActions() {
LOG->appendActiveLog("Test: ");
LOG->appendActiveLog( test );
LOG->appendActiveLog("\n");

    for( unsigned __int32 i = 0; i < ptrAutonomousElements->size(); ++i ) {
        ptrAutonomousElements->at( i ).ptrAutonomousElement->autonomousAction();
    }
}

This is the constructor, the print out of int var 'test' works jsut fine here:

AutonomousActionService::AutonomousActionService( string strElementID, string strClassName, FrameworkContainer* frameworkContainer ) : Service( strElementID, strClassName, frameworkContainer ) {
    ptrAutonomousElements = new vector<AutonomousElementRegistryEntry>();
    test = 1;
LOG->appendActiveLog("Test: ");
LOG->appendActiveLog( test );
LOG->appendActiveLog("\n");
}

Here is the header for the class:

class AutonomousActionService : public Service {
private:
    vector<AutonomousElementRegistryEntry> *ptrAutonomousElements;
    int test;
protected:
    AutonomousActionService();
public:
    AutonomousActionService( string strElementID, string strClassName, FrameworkContainer* frameworkContainer );
    ~AutonomousActionService();
    void handleEvent( Event event );

    bool registerAsAutonomousElement( string strElementId, IAutonomousElement* ptrElement );
    bool removeAutonomousElement( string strElementId );
    void processAutonomousActions();
};

Has any one heard of something like this before? Please help :)
==============================
A Developers Blog | Dark Rock Studios - My Site
Advertisement
solved it... Very strange problem, i'll post my solution when i ahve time and this red bull bing wears off tomorrow.
==============================
A Developers Blog | Dark Rock Studios - My Site

This topic is closed to new replies.

Advertisement