468,758 Members | 2,087 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,758 developers. It's quick & easy.

Compilation error on namespaces in system header debug.h

7
Hi,

I'm porting code from Windows to HP-UX 11, compiling with g++.
I'm getting a compilation error on the system's debug.h include file, which is included very indirectly through a series of other system include files. The one I am including is <map> .
The errors I am getting are:
/opt/hp-gcc-4.2.1/lib/gcc/ia64-hp-hpux11.23/4.2.1/../../../../include/c++/4.2.1/debug/debug.h: At global scope:
/opt/hp-gcc-4.2.1/lib/gcc/ia64-hp-hpux11.23/4.2.1/../../../../include/c++/4.2.1/debug/debug.h:49: error: expected identifier before numeric constant
/opt/hp-gcc-4.2.1/lib/gcc/ia64-hp-hpux11.23/4.2.1/../../../../include/c++/4.2.1/debug/debug.h:49: error: expected unqualified-id before numeric constant
/opt/hp-gcc-4.2.1/lib/gcc/ia64-hp-hpux11.23/4.2.1/../../../../include/c++/4.2.1/debug/debug.h:54: error: expected identifier before numeric constant
/opt/hp-gcc-4.2.1/lib/gcc/ia64-hp-hpux11.23/4.2.1/../../../../include/c++/4.2.1/debug/debug.h:54: error: expected unqualified-id before numeric constant
/opt/hp-gcc-4.2.1/lib/gcc/ia64-hp-hpux11.23/4.2.1/../../../../include/c++/4.2.1/debug/debug.h:59: error: expected identifier before numeric constant
/opt/hp-gcc-4.2.1/lib/gcc/ia64-hp-hpux11.23/4.2.1/../../../../include/c++/4.2.1/debug/debug.h:59: error: expected `;' before numeric constant
/opt/hp-gcc-4.2.1/lib/gcc/ia64-hp-hpux11.23/4.2.1/../../../../include/c++/4.2.1/debug/debug.h:59: error: expected unqualified-id before numeric constant
/opt/hp-gcc-4.2.1/lib/gcc/ia64-hp-hpux11.23/4.2.1/../../../../include/c++/4.2.1/debug/debug.h:60: error: expected identifier before numeric constant
/opt/hp-gcc-4.2.1/lib/gcc/ia64-hp-hpux11.23/4.2.1/../../../../include/c++/4.2.1/debug/debug.h:60: error: expected `;' before numeric constant
/opt/hp-gcc-4.2.1/lib/gcc/ia64-hp-hpux11.23/4.2.1/../../../../include/c++/4.2.1/debug/debug.h:60: error: expected unqualified-id before numeric constant

Following is the beginning of debug.h with the leading comment removed. The lines that get the errors are the declarations of nested namespaces, e.g. namespace __debug { }

Expand|Select|Wrap|Line Numbers
  1. #ifndef _GLIBCXX_DEBUG_MACRO_SWITCH_H
  2. #define _GLIBCXX_DEBUG_MACRO_SWITCH_H 1
  3.  
  4. /** Macros and namespaces used by the implementation outside of debug
  5.  *  wrappers to verify certain properties. The __glibcxx_requires_xxx
  6.  *  macros are merely wrappers around the __glibcxx_check_xxx wrappers
  7.  *  when we are compiling with debug mode, but disappear when we are
  8.  *  in release mode so that there is no checking performed in, e.g.,
  9.  *  the standard library algorithms.
  10. */
  11.  
  12. // Debug mode namespaces.
  13. namespace std
  14. {
  15.   namespace __debug { }
  16. }
  17.  
  18. namespace __gnu_cxx
  19. {
  20.   namespace __debug { };
  21. }
  22.  
  23. namespace __gnu_debug
  24. {
  25.   using namespace std::__debug;
  26.   using namespace __gnu_cxx::__debug;
  27. }
  28.  
  29.  
  30.  
  31.  
How do I get this to compile?

Thank you!

RO
Nov 1 '07 #1
3 2914
weaknessforcats
9,207 Expert Mod 8TB
I added a #endif at the end of your snippet and it compiled just fine using Visual Studio.NET 2005.
Nov 1 '07 #2
rorni
7
Thanks for your reply, you are right, the code is ok.
I found my problem and I'm quite ashamed to admit I didn't see it before.

In case anyone is interested. I must say to my defense that I have inherited the makefiles I am using from people before me, and that they work fine on Linux and on AIX. The problem was that they use a compilation flag -D__debug so when the debug.h file tries to define a namespace named __debug, it is actually using the defined flag, and so it thinks it is defining the namespace with the name '1'.

Sorry to waste anyone's time on this.

RO
Nov 4 '07 #3
weaknessforcats
9,207 Expert Mod 8TB
Sorry to waste anyone's time on this.
It wasn't a waste. The fact I got it to compile made you look elsewhere and you found the problem.
Nov 4 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

11 posts views Thread by Steven T. Hatton | last post: by
6 posts views Thread by Joachim | last post: by
reply views Thread by Jie | last post: by
2 posts views Thread by VB Programmer | last post: by
1 post views Thread by Paulustrious | last post: by
4 posts views Thread by Miroslaw Makowiecki | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.