Error compiling on SGI

Article ID: 981
Last updated: 05 Feb, 2008
Article ID: 981
Last updated: 05 Feb, 2008
Revision: 1
Views: 3709
Posted: 17 Sep, 1997
by Dean J.
Updated: 05 Feb, 2008
by Dean J.
Problem


When compiling source code on SGI I get the error:

    error(3114): identifier bool is undefined



Cause


The SGI C++ compiler has three primary object code generation options that can be selected from the command line.

  • -32 generates 32-bit objects
  • -n32 generates N32 objects
  • -64 generates 64-bit objects

The SGI documentation for their CC command says it best. Pay particular attention to the version of the compiler that gets invoked based upon the CPU architecture:

CC(1)                                                                    CC(1)

NAME
CC - C++ compiler

SYNOPSIS
CC [ option ] ... file ...

DESCRIPTION
CC, the SGI C++ compiler, produces files in the following formats: SGI
object code in elf format (the normal result), binary intermediate files,
and symbolic assembly language.

There are really two C++ compilers, a version which generates 64-bit or
N32 objects, and a 32-bit version which generates 32-bit objects. The
32-bit version is invoked when any of the options -32, -mips1, or -mips2
is specified, or by default on all non-R8000 based systems. The other
version is invoked by default on R8000 based systems or when any of the
options -n32, -64, -mips3, or -mips4 are specified. If -mips3, or -mips4.
are specified alone, -n32 is implied on non-R8000 systems whereas -64 is
implied on R8000 systems.
Some of the other options are recognized by
only one of the two compilers.

Note: The old cfront-based C++ compiler can be executed by specifying
the -use_cfront option to CC in 32-bit mode, or by executing
OCC(1). This option will not be available in future releases and
its use is being deprecated.

A simple test case demonstrates the problem:

#include   int main() {    bool t = true;    if(t)     cout << true << endl;   else     cout << false << endl;    return 0;  } 
The bool error only occurs when compiling 32-bit objects:

$ CC -n32 booltest.cpp
$ CC -64 booltest.cpp
$ CC -32 booltest.cpp
booltest.cpp, line 5: error(3114): identifier bool is undefined
bool t = true;
^

booltest.cpp, line 5: error(3114): identifier true is undefined
bool t = true;
^

2 errors detected in the compilation of booltest.cpp.
$

The reason for this is that the SGI compiler only defines the bool keyword in N32 and 64-bit compiler modes. Once again the SGI documentaton states it best:

   64-bit and N32 Options
The following options are recognized only in N32 or 64-bit mode. . . . -LANG:... Language feature option group: control the source language interpretation assumed by the compiler. The individual controls in this group are: bool[=(ON|OFF)] Enable the predefined bool data type, along with the predefined values true and false. Should be used with caution only to suppress this type in old code which defines bool itself. Because this option changes the mangling of function names with bool parameters, all files making up a program should be compiled with consistent options. (Default is ON.) . . .



Action


The net result is that if you have a non-R8000 based system you must use one of the compiler options -n32 or -64 to CC to eliminate the bool error.
This article was:   Helpful | Not helpful
Report an issue
Article ID: 981
Last updated: 05 Feb, 2008
Revision: 1
Views: 3709
Posted: 17 Sep, 1997 by Dean J.
Updated: 05 Feb, 2008 by Dean J.

Others in this category