Repeated Namespace Declaration

L

Leonel Galan

Hi all, I'm having trouble with VC++.

I have a namespace, named Compiler (I'm building one at university).
Some classes appear to be defined in Compiler::Compiler::Compiler or
just Compiler::Compiler.

It seems I'm having trouble with "#include ..." and "using namespace
Compiler;" declarations; When removing all "using namespace Compiler;"
since I'm inside the namespace Compiler I have some error as
unrecognized classes objects and stuff.

Any Suggestions?

More Info:

Many files use classes defined on other files. I'm not sure how to use
correctly the "#include ...". Just one time in the whole namespace?, in
every file that uses that file?, etc.

The project WORKS (good and without warnings) when I use "using
namespace Compiler;" but with the Compiler::Compiler::Compiler thing. I
just want to correct this issue for learning.

Thanks
 
B

Ben Voigt

Leonel Galan said:
Hi all, I'm having trouble with VC++.

I have a namespace, named Compiler (I'm building one at university).
Some classes appear to be defined in Compiler::Compiler::Compiler or
just Compiler::Compiler.

have anything looking like this?

namespace Compiler
{
#include <xyz.h>
};

xyz.h:
namespace Compiler
{
....
};

Make sure your #includes are outside the namespace scope to avoid nesting.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top