Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Pure Krome

Extern Class not Working / Linking - Please Help.

This topic is 5989 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

Hello All. I have a class (in a seperate file), and I get an UNDEFINED REFERENCE to it, when i try to link my code. DataStructures.h
        
#ifndef DATASTRUCTURES_H
#define DATASTRUCTURES_H


#include "Types.h"

#include <map>          // STL, for the collections




// ---- NO INCLUDES BELOW THIS LINE ----

#ifdef EXTERN

#undef EXTERN

#endif

#ifdef DATASTRUCTURES_CC

#define EXTERN

#else

#define EXTERN extern

#endif




class EVConnection;

class CLists {
  public:

     CLists ();
    ~CLists ();


    // Connection Functions

    void AddConnection (EVConnection connection);
    void RemoveConnection (const int iConnectionID);
    const int NumberConnections ();
    void RegisterAllConnections (fd_set &r, fd_set &w, fd_set &e);
    void UnRegisterAllConnections ();


  private:
    // Connections

    typedef std::map<int, EVConnection> ConnectionMap;
    ConnectionMap connectionMap;  // A Map of Connections

};



EXTERN CLists Lists;


#endif   // DATASTRUCTURES_H



  
DataStructures.cc
      
#include "DataStructures.h"

#include "Types.h"

#include "Network.h"

#include "Connection.h"


#include "Logger.h"



#define DATASTRUCTURES_CC



CLists::CLists ()
{
  // Nothing to do in this ctor, the default map ctor is fine.

}

// <SNIP THE REST>


  

Main.cc
      
#define MAIN_CC

#include <unistd.h>

#include <sys/time.h>

#include <sys/types.h>

#include <signal.h>

#include <errno.h>

#include <iostream>

#include <sqlplus.hh>


#include "Main.h"

#include "Configuration.h"

#include "DataStructures.h"

#include "Buffers.h"

#include "Utils.h"

#include "Signal.h"

#include "Time.h"

#include "Connection.h"

#include "Logger.h"

#include "Network.h"



using namespace std;

int main(int argc, char **argv)
{
...
...
Lists.RegisterAllConnections (r, w, e);
}

        
Code compiles perfectly, just fails on LINK. Any clues to why my EXTERN isn't working? -PK- Edited by - Pure Krome on February 25, 2002 5:55:13 AM

Share this post


Link to post
Share on other sites
Advertisement
quote:
Original post by Pure Krome
DataStructures.cc
#include "DataStructures.h"
...
#define DATASTRUCTURES_CC

Move the define before the include genius.

Why bother with all the #ifdefs and #undefs?

#ifndef DATASTRUCTURES_CC
extern
#endif
CLists Lists;

Then define DATASTRUCTURES_CC in onesource file and be done with it.

[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! ]
Thanks to Kylotan for the idea!

Share this post


Link to post
Share on other sites

  • 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!