0

stdbool.h contains this code:

#if __cplusplus < 201103L
/* Defining these macros in C++98 is a GCC extension.  */
#define bool    bool
#define false   false
#define true    true
#endif

Why does gcc need to redefine standard C++ types?

Kane
  • 5,595
  • 1
  • 18
  • 27
  • The real question is why you would ever include this header in a C++ file. The whole thing seems like it should be excluded if `__cplusplus` is defined. Maybe these definitions are there for backwards compatibility with C programs and/or older versions of the compiler? – Cody Gray - on strike Dec 09 '16 at 18:08

1 Answers1

1

Although #define fnord fnord won't generally change the way the identifier fnord is processed, it will cause #ifdef fnord to report the macro as defined. If other code might do something like

#ifndef true
#define true 1
#endif

Having a #define true true would cause such conditional definition to be skipped.

supercat
  • 77,689
  • 9
  • 166
  • 211