VS2010 strangest bug

Hello, first post on this forum! but the site helped me so much last 2 years, it's unbelivable lol


I've been using Visual Studio 2010 since the first RC but last month it started to go very bad... (It's the MSDNAA Ultimate edition btw)

The lastest bug i've encountered is that it reports me this when i compile one of my projects:


Error 1 error C2870: 'blahhh' : a namespace definition must appear either at file scope or immediately within another namespace definition
Error 2 error C2870: 'test' : a namespace definition must appear either at file scope or immediately within another namespace definition


MSDN says its a bad namespace declaration, that I understand perfectly but my code is this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#ifndef _GLOBAL_INCLUDED_
#define _GLOBAL_INCLUDED_

#define NAME		blahhh
#define BEGIN		namespace NAME {
#define END		}

BEGIN
END

namespace test {
	}

#endif 


That's literaly the whole file, and it reports the same C2870 error evertime i use NAME in my project.
I feel like it's trolling me...

Well for starters... those macros are awful. Don't try to turn C++ into BASIC.

Anyway this sounds like you're including this header at the wrong place in your file. Headers should pretty much almost always be #included globally (that is, not inside any function, class, or even inside another namespace). Can you post the cpp file that #includes this header?
I think he has been looking through some of the MS header files - which have similarly defined macros.
gulkan is right, I've been looking at the standard library for quite a while now, so I'm using some of their tricks in my code.


The error was really dumb actually... i included that file in a test header which i inadvertently included in my main... maybe i was just too tired to realize it yesterday.


problem solved!
thxs again!



btw i truncated those macros to be more concise
Last edited on
Topic archived. No new replies allowed.