strange pgCC compiler errors

I have a large set of C++ files that are being migrated from Athlon machine to a Quad Opteron. Naturally, my first step is to make sure everything compiles on the Opteron in 32-bit mode first, before moving to 64-bits. These machines have slightly different versions of the PGI compilers (5.1-2 vs 5.1-6 on the Opteron), but I can’t even compile a ‘Hello World’ code on the Opteron! It’s complaining about errors in a single PGI include file, and I have no idea how to resolve them - please help me!

The simple C++ program, test.cpp :

#include <iostream.h>
main ()
{
cout << "hello world!\n";
}

When compiled on the Athlon machine :

  • zaphod% which pgCC
    /usr/local/pgi/linux86/5.1/bin/pgCC
    zaphod% pgCC -c -V test.cpp

pgCC 5.1-2
Copyright 1989-2000, The Portland Group, Inc. All Rights Reserved.
Copyright 2000-2003, STMicroelectronics, Inc. All Rights Reserved.
Edison Design Group C/C++ Front End, version 3.3 (Nov 4 2003 16:45:25)
Copyright 1988-2003 Edison Design Group, Inc.

PGCC/x86 Linux/x86 5.1-2
Copyright 1989-2000, The Portland Group, Inc. All Rights Reserved.
Copyright 2000-2003, STMicroelectronics, Inc. All Rights Reserved.
zaphod%


when the same file is compiled (in 32-bit mode) on the Opteron :

  • shire% which pgCC
    /usr/local/pgi/linux86/5.1/bin/pgCC
    shire% pgCC -V -c test.cpp

pgCC 5.1-6
Copyright 1989-2000, The Portland Group, Inc. All Rights Reserved.
Copyright 2000-2003, STMicroelectronics, Inc. All Rights Reserved.
Edison Design Group C/C++ Front End, version 3.3 (Nov 4 2003 16:45:25)
Copyright 1988-2003 Edison Design Group, Inc.

“/usr/local/pgi/linux86/5.1/include/CC/stl/_limits.h”, line 155: error:
identifier “CHAR_BIT” is undefined
((int)((sizeof(_Int) * (CHAR_BIT))) - ((__imin == 0) ? 0 : 1))
^
detected during instantiation of class “std::_Integer_limits<_Int,
__imin, __imax, __idigits, __ismod> [with _Int=bool,
__imin=false, __imax=true, __idigits=1, __ismod=false]” at
line 245

… much more output removed …

“/usr/local/pgi/linux86/5.1/include/CC/stl/_limits.h”, line 502: error:
identifier “DBL_EPSILON” is undefined
static double _STLP_CALL epsilon() _STLP_NOTHROW { return DBL_EPSILON; }
^

39 errors detected in the compilation of “test.cpp”.
shire%

My guess is that your using the Athlon’s installation to compile on the Opteron. When you install on a system, the exact include files installed are dependent upon your OS and glibc version.

In particular, the “CHAR_BIT” problem occurs on an OS with GCC version 3.3. In one of your system include files, there is a #define of CHAR_BIT to CHAR_BIT. However, instead of defining CHAR_BIT in a header file, GCC has hard coded this value in the compiler itself. To work arround this we’ve added two header files (listed below) which defines this and other values. While installing directly on the Opteron is the best fix, adding these header files to “/usr/local/pgi/linux86/5.1/include” might get arround this problem.

Hope this helps,
Mat

limits.h

/*
  *      Copyright 2003, STMicroelectronics, Incorporated.
  *      All rights reserved.
  *
  *      STMICROELECTRONICS, INCORPORATED PROPRIETARY INFORMATION
  * This software is supplied under the terms of a license agreement
  * or nondisclosure agreement with STMicroelectronics and may not be
  * copied or disclosed except in accordance with the terms of that
  * agreement.
  */


/* supply suse 8.2, gcc 3.3 predefines
    these do not exist in any include file.
    they exist in the gcc compiler.
  */

#define __CHAR_BIT__       8
#define __SCHAR_MAX__      127
#define __INT_MAX__        2147483647
#define  __SHRT_MAX__      32767
#define __LONG_MAX__       2147483647L



#include_next<limits.h>

float.h

/*
  *      Copyright 2003, STMicroelectronics, Incorporated.
  *      All rights reserved.
  *
  *      STMICROELECTRONICS, INCORPORATED PROPRIETARY INFORMATION
  * This software is supplied under the terms of a license agreement
  * or nondisclosure agreement with STMicroelectronics and may not be
  * copied or disclosed except in accordance with the terms of that
  * agreement.
  */

/* supply suse 8.2, gcc 3.3 predefines
    these do not exist in any include file.
    they exist in the gcc compiler.
  */

#define __FLT_MAX_EXP__    128
#define __FLT_MIN_10_EXP__ (-37)
#define __FLT_MIN_EXP__   (-125)
#define __FLT_DIG__        6
#define __FLT_MANT_DIG__   24
#define __FLT_MAX__        3.40282347e+38F
#define __FLT_MIN__        1.17549435e-38
#define __FLT_RADIX__      2
#define __FLT_MAX_10_EXP__ 38
#define __FLT_EPSILON__    1.19209290e-7F
#define __FLT_EVAL_METHOD__ 2
#define __DECIMAL_DIG__    21

#define __DBL_MANT_DIG__   53
#define __DBL_DIG__        15
#define __DBL_MIN_EXP__    (-1021)
#define __DBL_MIN_10_EXP__ (-307)
#define __DBL_MAX_EXP__    1024
#define __DBL_MAX_10_EXP__ 308
#define __DBL_MAX__        1.7976931348623157e+308
#define __DBL_EPSILON__    2.2204460492503131e-16
#define __DBL_MIN__        2.2250738585072014e-308


/* pgcc Long double on 32 bit is same as double */
/* unlike gcc  3.3 */
#define __LDBL_MANT_DIG__   53
#define __LDBL_DIG__        15
#define __LDBL_MIN_EXP__    (-1021)
#define __LDBL_MIN_10_EXP__ (-307)
#define __LDBL_MAX_EXP__    1024
#define __LDBL_MAX_10_EXP__ 308
#define __LDBL_MAX__        1.7976931348623157e+308
#define __LDBL_EPSILON__    2.2204460492503131e-16
#define __LDBL_MIN__        2.2250738585072014e-308




#include_next<float.h>

A simple re-install did the trick!

This is the key :

When you install on a system, the exact include files installed are dependent upon your OS and glibc version.

The Opteron machine had been running SuSE Linux Enterprise Server version 8.1 when the PGI compilers were installed. The machine was just recently been upgraded to version 9, which included upgrades for glibc, but the PG C and FORTRAN compilers worked just fine for everything I was doing, so I didn’t think anything special needed to be done. The error only came up when I started using the C++ compiler many days later. Lesson learned.

Thanks for your help!