C doesn't have any built-in boolean types. What's the best way to use them in C?
转载于:https://stackoverflow.com/questions/1921539/using-boolean-values-in-c
C doesn't have any built-in boolean types. What's the best way to use them in C?
转载于:https://stackoverflow.com/questions/1921539/using-boolean-values-in-c
Option 1
typedef int bool;
#define true 1
#define false 0
Option 2
typedef int bool;
enum { false, true };
Option 3
typedef enum { false, true } bool;
Option 4 (C99)
#include <stdbool.h>
If you are undecided, go with #3!