There are still some environments where C may not have easy access to a stdbool
header file. That's easy to fix, of course. The basic pattern is to typedef
an integer type as a boolean type, and then define some symbols for true and false. It's a pretty standard pattern, three lines of code, and unless you insist that FILE_NOT_FOUND
is a boolean value, it's pretty hard to mess up.
Julien H was compiling some third-party C code, specifically in Visual Studio 2010, and as it turns out, VS2010 doesn't support C99, and thus doesn't have a stdbool
. But, as stated, it's an easy pattern to implement, so the third party library went and implemented it:
#ifndef _STDBOOL_H_VS2010
#define _STDBOOL_H_VS2010
typedef int bool;
static bool true = 1;
static bool false = 0;
#endif
We've asked many times, what is truth? In this case, we admit a very post-modern reality: what is "true" is not constant and unchanging, it cannot merely be enumerated, it must be variable. Truth can change, because here we've defined true
and false
as variables. And more than that, each person must identify their own truth, and by making these variables static
, what we guarantee is that every .c
file in our application can have its own value for truth. The static
keyword, applied to a global variable, guarantees that each .c
file gets its own scope.
I can only assume this header was developed by Jacques Derrida.