namespace issues

S

Steffen Hampel

I got an rather large project which i recently startet to split up into
namespaces.
At a certain point the compiler (MSVC 6.0 sp5) began to give me C2871 errors
( 'name' : does not exist or is not a namespace ). I'am using an scheme
like this:

[header1.h]

namespace A {
// class declaration

}

[sourcefile1.cpp]
#include "header1.h"
#include<something>

namespace A{

// class definition
}

[header2.h]

namespace B {
// class declaration

}

[sourcefile2.cpp]
#include "header1.h"
#include "header2.h"
#include<something>

namespace B{
using namespace A; // error C2871
// class definition
}

Do you have any idea what i'm doing wrong? Or is this an compiler issue,
since i'm using 5-6 different namespaces distributet over 30 files and and
are cross referencing each other in the implementation sourcefiles.

I appreciate your help!
 
S

Steffen Hampel

eiji said:
This could be VC++ issue which does not belong to this group.

But first, have you figured out the msdn error discription?

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore98/html/c2871.asp
You are sure, not running into one of these errors?

Regards,
Sascha

I'm aware of the purpose of errorcodes, and i always lookup all the sources
i know (including google) to solve a problem, before i would bother you with
my questions.

I'm sure i have declared the namespaces i reference and the that there are
no name clashes.
At least i did all the obvious stuff right.
Maybe there is a mistake caused by all the cross referenzing or the
preprozessor has deleted something.
I have no clue. I hope somebody had this Problem before and can give me a
hint to work around.

Regards
Steffen
 
P

paulius-maruska

Are you sure the #include<something> part doesn't declaire any symbols
that would generate nameclashes?

Just a sugestion - try prefix something to the namespace A (make it
temp_A or something like that), if the error is still there, then it's
not a nameclash for sure.
 
M

Mike Wahler

Steffen Hampel said:
I got an rather large project which i recently startet to split up into
namespaces.
At a certain point the compiler (MSVC 6.0 sp5) began to give me C2871
errors
( 'name' : does not exist or is not a namespace ). I'am using an scheme
like this:

[header1.h]

namespace A {
// class declaration

}

[sourcefile1.cpp]
#include "header1.h"
#include<something>

namespace A{

// class definition
}

[header2.h]

namespace B {
// class declaration

}

[sourcefile2.cpp]
#include "header1.h"
#include "header2.h"
#include<something>

namespace B{
using namespace A; // error C2871
// class definition
}

Do you have any idea what i'm doing wrong? Or is this an compiler issue,
since i'm using 5-6 different namespaces distributet over 30 files and and
are cross referencing each other in the implementation sourcefiles.

I recreated your example above using VC6.0 (but I have SP6),
but without the #include<something> (what is that supposed to
represent?), and I got a clean compile with no errors.

Perhaps it's something :)-) ) in your <something> header?

-Mike
 
S

spacksack

Mike said:
Steffen Hampel said:
I got an rather large project which i recently startet to split up into
namespaces.
At a certain point the compiler (MSVC 6.0 sp5) began to give me C2871
errors
( 'name' : does not exist or is not a namespace ). I'am using an scheme
like this:

[header1.h]

namespace A {
// class declaration

}

[sourcefile1.cpp]
#include "header1.h"
#include<something>

namespace A{

// class definition
}

[header2.h]

namespace B {
// class declaration

}

[sourcefile2.cpp]
#include "header1.h"
#include "header2.h"
#include<something>

namespace B{
using namespace A; // error C2871
// class definition
}

Do you have any idea what i'm doing wrong? Or is this an compiler issue,
since i'm using 5-6 different namespaces distributet over 30 files and and
are cross referencing each other in the implementation sourcefiles.

I recreated your example above using VC6.0 (but I have SP6),
but without the #include<something> (what is that supposed to
represent?), and I got a clean compile with no errors.

Perhaps it's something :)-) ) in your <something> header?

-Mike

The #include<something> means that there are other headers included
besides the "header1.h" (standart STL headers as well as custum
headers).
if you have an idea what could be wrong in these headers, that affects
my templates, i would be happy to know.

I'm using VS6 SP5 since the SP6 doesn't work with the "processor Pack"
Update from M$.

-Steffen
 
M

Mike Wahler

Mike said:
Steffen Hampel said:
I got an rather large project which i recently startet to split up into
namespaces.
At a certain point the compiler (MSVC 6.0 sp5) began to give me C2871
errors
( 'name' : does not exist or is not a namespace ). I'am using an
scheme
like this:

[header1.h]

namespace A {
// class declaration

}

[sourcefile1.cpp]
#include "header1.h"
#include<something>

namespace A{

// class definition
}

[header2.h]

namespace B {
// class declaration

}

[sourcefile2.cpp]
#include "header1.h"
#include "header2.h"
#include<something>

namespace B{
using namespace A; // error C2871
// class definition
}

Do you have any idea what i'm doing wrong? Or is this an compiler
issue,
since i'm using 5-6 different namespaces distributet over 30 files and
and
are cross referencing each other in the implementation sourcefiles.

I recreated your example above using VC6.0 (but I have SP6),
but without the #include<something> (what is that supposed to
represent?), and I got a clean compile with no errors.

Perhaps it's something :)-) ) in your <something> header?

-Mike

The #include<something> means that there are other headers included
besides the "header1.h"

I suspected as much, but no way could anyone know without
your telling use.
(standart STL headers as well as custum
headers).

The standard headers shouldn't be a problem. But of course
there could easily be a problem in one or more of your
'custom' headers.
if you have an idea what could be wrong in these headers,


How on Earth could I know or guess without seeing them?
that affects
my templates, i would be happy to know.

The first thing to do would be to eliminate them. If the
problem goes away, then of course the problem is there.
Then start adding them back one at a time until the
problem reappears. That's a pretty basic problem-solving
technique.

I'm using VS6 SP5 since the SP6 doesn't work with the "processor Pack"
Update from M$.

I doubt that service pack version is the trouble.

-Mike
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top