Compilation error on namespaces in system header debug.h

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 { }

#ifndef _GLIBCXX_DEBUG_MACRO_SWITCH_H
#define _GLIBCXX_DEBUG_MACRO_SWITCH_H 1

/** Macros and namespaces used by the implementation outside of debug
 *  wrappers to verify certain properties. The __glibcxx_requires_xxx
 *  macros are merely wrappers around the __glibcxx_check_xxx wrappers
 *  when we are compiling with debug mode, but disappear when we are
 *  in release mode so that there is no checking performed in, e.g.,
 *  the standard library algorithms.
*/

// Debug mode namespaces.
namespace std
{
  namespace __debug { }
}

namespace __gnu_cxx
{
  namespace __debug { };
}

namespace __gnu_debug
{
  using namespace std::__debug;
  using namespace __gnu_cxx::__debug;
}



How do I get this to compile?

Thank you!

RO

Looks like you need to predefine some macros so that to the compiler it appears in release mode.

If you are porting Windows code to HPUX 11.23 using gcc, have you first ported it to Linux using gcc? It reduces the number of unknowns.

Alternatively use HPUX's aCC.

Thanks for your reply!
Before I even read it I found my problem and I'm quite ashamed to admit I didn't see it before.

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.
In case anyone is interested, 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

No worries. We have all done similar, I'm sure.

It helps me out! Thank you