pgCC error on STL <vector>

Hi all,

I encountered a strange error in compiling. The error message likes
identifier “CHAR_BIT” is undefined.

This happens once I tried to include in the code. Does anyone see this before? How to fix it ? Thanks.


Hi best,

What version of the compilers do you have? Also, what OS are you using?

This was a GNU compatabilty issue, but should have been fixed a few years ago.


The version is 6.0.4. The OS is linux 2.6.5. X86_64. Is it because of the installation problem? Or should I use some switches in the command line? Thanks.

Hi Hua,

The problem is that GNU changed sometime around GCC version 3.3 the limits.h header file so that “CHAR_BIT” is redfined to be “CHAR_BIT”. Since “CHAR_BIT” is defined internally by the GNU Compiler and not part of a system header file, older PGI compilers do not have a definition for this identifier.

To fix, we began including our own limits.h file which includes these identifiers. The easiest route would be to upgrade to the latest compiler version, but you might be able to add the following limits.h file to your PGI include directory.

 *      Copyright 2003, STMicroelectronics, Incorporated.
 *      All rights reserved.
 * 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 gcc 3.3 compiler predefines
   They do not exist in any include file

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


Hope this helps,

Hi, Mat,

Thank you for the help. The problem solved!