Loading 2 dll troubles

This is a discussion on Loading 2 dll troubles within the C++ Programming forums, part of the General Programming Boards category; I have been trying to load up 2 dll files under the following names. #include "gamedll/gamedll.h" #include "gamefunc/gamefunc.h" But for ...

  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    34

    Loading 2 dll troubles

    I have been trying to load up 2 dll files under the following names.

    #include "gamedll/gamedll.h"
    #include "gamefunc/gamefunc.h"

    But for some reason the files are conflicting with each other I don't know why.

    gamedll.h by it self loads up fine. that if gamefunc is loaded after now if its loaded before,
    its the other way around gamefunc.h loads up fine but then I have gamedll.h problems.

    Here are their contents.

    gamedll.h:
    Code:
    #ifndef _DLL_H_
    #define _DLL_H_
    
    #if BUILDING_DLL
    # define DLLIMPORT __declspec (dllexport)
    #else /* Not BUILDING_DLL */
    # define DLLIMPORT __declspec (dllimport)
    #endif /* Not BUILDING_DLL */
    
    
    bool ReadINI( char const * pFile, char const * pSection, char const * pKey, char* pBuffer, unsigned int bufferLength, char const * pDefaultValue =0 );
    void WriteINI(char* sFile, char* AppName, char* Key, char* sString);
    
    
    #endif /* _DLL_H_ */
    gamefunc.h
    Code:
    #ifndef _DLL_H_
    #define _DLL_H_
    
    #if BUILDING_DLL
    # define DLLIMPORT __declspec (dllexport)
    #else /* Not BUILDING_DLL */
    # define DLLIMPORT __declspec (dllimport)
    #endif /* Not BUILDING_DLL */
    
    
    void s_onmain(SOCKET USocket,char*buffer,int Index);
    void s_ondisconnect(int Index);
    void s_onconnect(SOCKET NSocket);
    void s_onload();
    
    
    #endif /* _DLL_H_ */
    Thanks for your time
    Its Really All up to you.

  2. #2
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    use different header guards for each of your header files.

  3. #3
    Registered User
    Join Date
    Nov 2006
    Posts
    519
    both includes say
    #ifndef _DLL_H_
    #define _DLL_H_
    so when the first was included and has declared it's stuff the second is ignored because _DLL_H is already defined.

  4. #4
    Registered User
    Join Date
    May 2006
    Posts
    34
    so what should i do?
    Its Really All up to you.

  5. #5
    Registered User
    Join Date
    Nov 2006
    Posts
    519
    read about preprocessor defines or "include guards". its pretty easy, you just have to choose different ones for your includes. for example let them match the filename in all upper case

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Loading a DLL that is not in the same directory as the executable
    By starcatcher in forum Windows Programming
    Replies: 10
    Last Post: 12-13-2008, 06:05 AM
  2. Explicit DLL loading
    By true_organs in forum Windows Programming
    Replies: 6
    Last Post: 05-24-2008, 01:26 PM
  3. Troubles Calling a DLL
    By jamez05 in forum C++ Programming
    Replies: 2
    Last Post: 12-02-2005, 11:00 AM
  4. Loading a DLL at runtime
    By filler_bunny in forum Windows Programming
    Replies: 9
    Last Post: 02-23-2003, 07:03 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21