Results 1 to 5 of 5

Thread: Linking

  1. #1

    Thread Starter
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024

    Linking

    Ok this is about to drive me nutz.

    I have 4 .cpp file and 5 .h files
    There is a main.h & .cpp which contains the main program
    There is a ListCtrl.h & .cpp which is a wrapper for a listview
    There is a Grab.h & .cpp which grabs stuff from a file
    There is another .h & .cpp thats not important

    Finally there is a custheader.h which has all the <headers> like <string> <map> <vector> etc.

    Main.h has all the "headers" in it.

    All the other .h files just has "Main.h" included.

    All the .h have #ifndef __NAME_H__ #def __NAME_H__ in them to stop them from getting defined multiple times.

    Ok now all that works great, except I have a struct that is in Grab.h, and when I try to use it in ListCrtl.h it tells me that the struct isnt defined. Of course when I try to just add the struct to header it tells me its now trying to be redefined. I have tried to include the Grab.h and that doesnt work because it already linked when main.h get compiled.

    So how do I fix this up?
    MSVS 6, .NET & .NET 2003 Pro
    I HATE MSDN with .NET & .NET 2003!!!

    Check out my sites:
    http://www.filthyhands.com
    http://www.techno-coding.com


  2. #2
    Frenzied Member
    Join Date
    Jul 2002
    Posts
    1,370
    Declare the struct as extern.

  3. #3

    Thread Starter
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    I thought of that but when I do that I get error C2159: more than one storage class specified

    Here is what the struct looks like, maybe that has something to do with it:

    Code:
    struct FILE_S
    {
    	string	sName;
    	string	sExt;
    	long	lSize;
    };
    
    typedef vector<FILE_S> typeFILE;
    
    struct DIR_S
    {
    	bool		bScanned;
    	int		iFiles;
    	long		lTotalSize;
    	int		iTXTs;
    	typeFILE	vecFiles;
    };
    MSVS 6, .NET & .NET 2003 Pro
    I HATE MSDN with .NET & .NET 2003!!!

    Check out my sites:
    http://www.filthyhands.com
    http://www.techno-coding.com


  4. #4
    Frenzied Member
    Join Date
    Jul 2002
    Posts
    1,370
    Didja try:
    Code:
    #ifndef FILE_TEMPLATE
    #define FILE_TEMPLATE 
    struct FILE_S
    {
    	string	sName;
    	string	sExt;
    	long	lSize;
    };
    
    typedef vector<FILE_S> typeFILE;
    
    struct DIR_S
    {
    	bool		bScanned;
    	int		iFiles;
    	long		lTotalSize;
    	int		iTXTs;
    	typeFILE	vecFiles;
    };
    #endif
    in each of the header files? like grab.h, etc.

  5. #5

    Thread Starter
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    Yeah all the headers have that
    I see this http://www.codeguru.com/forum/showth...hreadid=231048
    I gave it a try using
    Code:
    class LIST_CL
    {
    	private:
    		//Functions
    		
    		//VARs
    		LV_COLUMN		m_lvc;
    		HWND			m_hWnd;
    		int			m_iCols;
    
    	public:
    		//Functions
    		LIST_CL();
    		~LIST_CL();
    
    		struct p_Point;
    		bool	AddItem(p_Point *File);
    }
    But I get told that it cant convert from p_Point to DIR_S
    MSVS 6, .NET & .NET 2003 Pro
    I HATE MSDN with .NET & .NET 2003!!!

    Check out my sites:
    http://www.filthyhands.com
    http://www.techno-coding.com


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width