CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Threaded View

  1. #1
    Join Date
    May 2009
    Posts
    19

    Type not found problems

    Hi all,

    I'm having some rather odd problems with includes. I declare and define a class, along with some methods, in one header file. (They are in a namespace) I then include that header file in numerous other files. In one of the files it's included in (another header file), none of the methods/typedefs/classes defined in the header file can be found, but in all other files, everything is found properly. I'm sure it has nothing to do with the fact the everything is in a namespace, because when I remove the namespace (make everything part of the global namespace), nothing changes.

    Here are some code fragments... I can't post all of it, because it's a large project, and I haven't been able to reproduce it anywhere else, so no SSCCE either

    io.hpp//the main file where the class/typedef/methods are defined
    Code:
    namespace io{
    typedef int IChar;
    
    class InputData{
    	std::istream * inStream;
    	std::string fileName;
    	int onCharNum;
    public:
    	InputData(std::istream* stream, std::string filename,
    			int cNum);
    	InputData(std::string fileName);
    	InputData(std::string fileName, int cNum);
    	~InputData();
    	IChar read();
    	std::string readToDelim(char delim='\n');
    	int getCharNumber(){return onCharNum;}
    	std::string getFileName(){return fileName;}
    };
    
    ...//some other methods
    
    }//close namespace
    objManage.hpp//the header file where the types cannot be found
    Code:
    #include <list>
    #include <map>
    #include <string>
    #include <iostream>
    #include "io.hpp"
    #include "../shared/opcode.hpp"
    #include "osdep/threading.hpp"
    
    ...//forward declarations of structs and classes
    
    struct MethodLocation{
    	std::string fileName;
    	int cNumber;
    	MethodLocation(io::InputData* copyPos);//believes io::InputData does not exist
    	MethodLocation(std::string fName,int cNumber);
    };
    
    class Method{
    public:
    	Method();
    	virtual ~Method();
    	virtual void call(Variable* params=NULL, int params=0);
    	std::string getName(){return name;}
    	TypeData getType(){return returnType;}
    	std::list<VariableBase> getParams(){return params;};
    protected:
    	Method(std::string name,TypeData returnType);
    	std::string name;
    	TypeData returnType;
    	std::list<VariableBase> params;
    private:
    
    	io::InputData* input;//doesn't think that io::InputData exists
    	MethodLocation* inProvider;
    	bool reloading;
    	Notifier* reloadWait;
    	Lock* reloadLock;
    	static void reload(void* modMethod);
    	void setReload(bool reload);
    };
    I realize that there isn't really any way to understand what the code is actually doing, but as I said, if I tried to post the whole code, it would be a mess. However, the code is in the Subversion repository at https://arlix.svn.sourceforge.net/svnroot/arlix if you want to take a look, and I am willing to post any additional code that might be needed.

    I'm using the MinGW port of g++ as my compiler, under Eclipse CDT.

    Thanks in advance,
    Singing Boyo

    [edit]
    What do you know, SVN repositories can be viewed via a regular browser, at least on Sourceforge. So, here's a bit more information on the repository - the files are under trunk/src/vm.

    Also, the code is Win32 dependent for full compilation.

    Thanks again
    [/edit]
    Last edited by Singing Boyo; March 30th, 2010 at 08:42 PM.

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

Featured