[PATCH] Convert the C code to using stdbool and true/false

Dirk Hohndel dirk at hohndel.org
Wed Jan 15 18:27:53 UTC 2014


On Wed, 2014-01-15 at 12:25 -0800, Thiago Macieira wrote:
> On quarta-feira, 15 de janeiro de 2014 19:54:41, Anton Lundin wrote:
> >  #ifdef __cplusplus
> >  extern "C" {
> > -#else
> > -#if __STDC_VERSION__ >= 199901L
> > -#include <stdbool.h>
> > -#ifndef TRUE
> > -#define TRUE true
> > -#endif
> > -#ifndef FALSE
> > -#define FALSE false
> > -#endif
> > -#else
> > -typedef int bool;
> > -#ifndef TRUE
> > -#define TRUE 1
> > -#endif
> > -#ifndef FALSE
> > -#define FALSE 0
> > -#endif
> > -#endif
> >  #endif
> > +#include <stdbool.h>
> 
> Strictly speaking, we shouldn't include stdbool.h in C++ code.
> 
> So this should be:
> 
> #ifdef __cplusplus
> extern "C"
> #else
> #include <stdbool.h>
> #endif
> 
> However, both GCC and Clang allow for it, so I don't see a problem.

I changed it anyway.

> MSVC 2012 doesn't have it, but 2013 does -- Microsoft finally added some C99 
> features.

I seem to remember that I added all these silly defines because the
compile was broken on one of my platforms. Since I can't remember which
one it was I'll take the patch (with Thiago's modification), push it out
and wait for things to break.

Much easier than doing all the hard work of "maintaining" by myself :-)

/D



More information about the subsurface mailing list