EmailSurfer
asked on
Compiler namespace error?
Hello,
Could anyone advise? I have an example code which includes a namespace jminus. But when I try to reference the code inside the namespace from a separate file main.cpp many errors are displayed including :
std::auto_ptr< jminus::abstract_interpret er >
jminus' has not been declared
I posted the code at http://members.aol.com/emailsurfer95/ and wondered if the code could not be posted. It was a friends example and I am not sure if they would like it posted.
Many thanks
Could anyone advise? I have an example code which includes a namespace jminus. But when I try to reference the code inside the namespace from a separate file main.cpp many errors are displayed including :
std::auto_ptr< jminus::abstract_interpret
jminus' has not been declared
I posted the code at http://members.aol.com/emailsurfer95/ and wondered if the code could not be posted. It was a friends example and I am not sure if they would like it posted.
Many thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you for replying.
In my friends version, they declared the #include statements in the main.cpp and some of the .hpp files as:
#include "jminus/some.hpp"
Could anyone advise if the jminus used in the #include statements means the files hpp files should be placed in a folder named jminus and the main.cpp outside this folder?
I posted the new verions at:
http://members.aol.com/emailsurfer95/
I would much appreciate if anyone could try and compile the main.cpp to see if you also recieve the many errors?
thank you
In my friends version, they declared the #include statements in the main.cpp and some of the .hpp files as:
#include "jminus/some.hpp"
Could anyone advise if the jminus used in the #include statements means the files hpp files should be placed in a folder named jminus and the main.cpp outside this folder?
I posted the new verions at:
http://members.aol.com/emailsurfer95/
I would much appreciate if anyone could try and compile the main.cpp to see if you also recieve the many errors?
thank you
>> Could anyone advise if the jminus used in the #include statements means the files hpp files should be placed in a folder named jminus and the main.cpp outside this folder?
yes
>>I would much appreciate if anyone could try and compile the main.cpp to see if you also recieve the many errors?
i cant try to compile because in file 'statement.hpp' there is no any decaration of 'statement', its size == 0.
yes
>>I would much appreciate if anyone could try and compile the main.cpp to see if you also recieve the many errors?
i cant try to compile because in file 'statement.hpp' there is no any decaration of 'statement', its size == 0.
ASKER
Thanks
I created a folder c++, then created a second folder inside called jminus where I placed all the .hpp files. I placed the main.cpp file in the c++ folder.
When I compiled the main.cpp file, I got the error:
jminus' has not been declared
pointing to the line std::auto_ptr< jminus::abstract_interpret er >
This was the same error as before.
I created a folder c++, then created a second folder inside called jminus where I placed all the .hpp files. I placed the main.cpp file in the c++ folder.
When I compiled the main.cpp file, I got the error:
jminus' has not been declared
pointing to the line std::auto_ptr< jminus::abstract_interpret
This was the same error as before.
>> I created a folder c++, then created a second folder inside called jminus where I placed all the .hpp files. I placed the main.cpp file in the c++ folder.
did you include in main.cpp header file in which defined namespace 'jminus' 7
#include "jminus/HEADER_WHERE_JMINU S_NM_DEFIN ED.hpp"
did you include in main.cpp header file in which defined namespace 'jminus' 7
#include "jminus/HEADER_WHERE_JMINU
ASKER
Does this code point tot he jminus namespace?
std::auto_ptr< jminus::abstract_interpret er >
To remove the compiler error:
jminus' has not been declared
error pointing to the line std::auto_ptr< jminus::abstract_interpret er >
Should I include the #include in main.cpp
#include "jminus/abstract_interpret er.hpp"
abstract_interpreter.hpp is where the jminus namespace is declared.
Thank you
std::auto_ptr< jminus::abstract_interpret
To remove the compiler error:
jminus' has not been declared
error pointing to the line std::auto_ptr< jminus::abstract_interpret
Should I include the #include in main.cpp
#include "jminus/abstract_interpret
abstract_interpreter.hpp is where the jminus namespace is declared.
Thank you
>>Should I include the #include in main.cpp
#include "jminus/abstract_interpret er.hpp"
abstract_interpreter.hpp is where the jminus namespace is declared.
YYYYES! :))
to have access to some namespace you must include header where this namespace declared.
#include "jminus/abstract_interpret
abstract_interpreter.hpp is where the jminus namespace is declared.
YYYYES! :))
to have access to some namespace you must include header where this namespace declared.
ASKER
Thank you,
Many of the errors have now passed.
Could I ask finally before closing the question. The cpp file includes an exception in the main here is the catch:
catch( jminus::interpreter_except ion& e )
{
std::cerr << "Interpreter exception: [" << e.what() << "] reading script " << argv[ file_number ] << std::endl;
result = EXIT_FAILURE;
}
In this catch, will I need to write my own exception. And could you possibly advise how to start this?
Many thanks
Many of the errors have now passed.
Could I ask finally before closing the question. The cpp file includes an exception in the main here is the catch:
catch( jminus::interpreter_except
{
std::cerr << "Interpreter exception: [" << e.what() << "] reading script " << argv[ file_number ] << std::endl;
result = EXIT_FAILURE;
}
In this catch, will I need to write my own exception. And could you possibly advise how to start this?
Many thanks
This might be because of two reasons.
1. Include the jminus header.
a. The compiler couldn't locate this namespace while compiling your code.
2. Can you try with using namespace.
Can you try your code with
using namespace jminus;
You are getting namespace error, then the location of the namespace couldn't find.