1

I'm trying to build a program on Solaris 10 that includes stdbool.h.

For the C compiler I've added -xc99=all, and I'm trying to use -xlang=c99 for the C++ compiler, but still it gives me:

"/usr/include/stdbool.h", line 42: Error, usererror: #error "Use of is valid only in a c99 compilation environment.".

The full command line looks like:

CC -xlang=c99 -DHAVE_CONFIG_H -I. -xldscope=hidden -D_REENTRANT -mt -compat=5 \
-library=stlport4 -template=no%extdef -g -DDEBUG -xwe -xport64 -errtags=yes \
-erroff=attrskipunsup,doubunder,reftotemp,inllargeuse,truncwarn1,signextwarn,inllargeint \
-errwarn=%all -erroff=truncwarn1,signextwarn,notused,inllargeuse,wunreachable \
-c backfill.cc  -KPIC -DPIC -o .libs/ep_la-backfill.o
gideon
  • 19,329
  • 11
  • 72
  • 113
trondn
  • 379
  • 1
  • 2

1 Answers1

1

It makes not much sense to compile C++ code with C99 options. In any case for C++ you definitively shouldn't use stdbool.h, bool is a keyword in C++.

Jens Gustedt
  • 76,821
  • 6
  • 102
  • 177
  • I'm not including the headerfile directly, it's included from another headerfile I'm including.... I'd like to avoid having to go around adding #ifndef __cplusplus in all of the related sources... – trondn Jul 31 '11 at 20:45
  • @Mahesh, I know what the C99 `_Bool` data type is. Therefore precisely my answer. It makes no sense at all to have that included in a C++ source. `stdbool.h` adds a `#define` of `bool` to `_Bool` which in turn C++ doesn't have. You *have* to protect against this with guards when you compile C++, and I think this is exactly what compilere message says. C99 and C++ are incompatible in many places. – Jens Gustedt Jul 31 '11 at 21:23