Getting Compilation error when referencing stdbool.h header file (Doc ID 1346778.1)

Last updated on JANUARY 25, 2012

Applies to:

Precompilers - Version: 11.2.0.1 and later   [Release: 11.2 and later ]
Information in this document applies to any platform.

Symptoms

Use of the stdbool.h header file is valid only in a C99 compilation environments.
  • Warning exists only on Solaris 10.
  • Solaris 9 does not have C99 support.
The following sample code will illustrate the issue.

#include <stdbool.h>
#include <stdio.h>
#include <string.h>

int main(int argc, char *argv[])
{
    bool fst = true;
    while (1)
    {
        if (fst)
        {
            printf("First time!\n");
            fst = false;
        }
        else
        {
            printf("Not first :(\n");
            break;
        }
    }
}

Getting the following compilation errors when stdbool.h is referenced.
There are 2 scenarios that illustrate the issue. The first scenario executes the Pro*C precompiler directly and the second scenario uses the Oracle provided make file.

Scenario 1 - using Pro*C directly

> proc include=/usupport/64bit/app/oracle/product/11.2.0.1/precomp/public include=/usupport/64bit/app/oracle/product/11.2.0.1/rdbms/public include=/usupport/64bit/app/oracle/product/11.2.0.1/rdbms/demo include=/usupport/64bit/app/oracle/product/11.2.0.1/plsql/public iname=bool_test.c oname=bool_test.tmp

Syntax error at line 7, column 10, file bool_test.c:
Error at line 7, column 10 in file bool_test.c
bool fst = true;
.........1
PCC-S-02201, Encountered the symbol "fst" when expecting one of the following:

; , = : ( [ * ? | & < > + - / % . ^ *= /= %= += -= <<= >>=
&&= ||= ^= | & == != <= >= << >> ++ -- ->
The symbol ";" was substituted for "fst" to continue.

Error at line 0, column 0 in file bool_test.c
PCC-F-02102, Fatal error while doing C preprocessing


Scenario 2 - using the Oracle provided make file

> make -f demo_proc.mk build EXE=bool_test OBJS=bool_test.o

"/usr/include/stdbool.h", line 42: #error: "Use of <stdbool.h> is valid only in a c99 compilation environment."
cc: acomp failed for bool_test.c
*** Error code 1
make: Fatal error: Command failed for target `bool_test.o'

Cause

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms