Jump to content
  • Advertisement
Sign in to follow this  

C++ Static Link Lib pointer problem!!

This topic is 4232 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

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

Here is the header for the class:
class AutonomousActionService : public Service {
    vector<AutonomousElementRegistryEntry> *ptrAutonomousElements;
    int test;
    AutonomousActionService( string strElementID, string strClassName, FrameworkContainer* frameworkContainer );
    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 :)

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!