Here's all .h files I've included so far,but non have the definition of bool
:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <pthread.h>
#include <netdb.h>
#include <fcntl.h>
#include <unistd.h>
#include <event.h>
Which file does define bool
?
It's part of C99 and defined in POSIX definition stdbool.h.
bool
is just a macro that expands to _Bool
. You can use _Bool
with no #include
very much like you can use int
or double
; it is a C99 keyword.
The macro is defined in <stdbool.h>
along with 3 other macros.
The macros defined are
bool
: macro expands to _Bool
false
: macro expands to 0
true
: macro expands to 1
__bool_true_false_are_defined
: macro expands to 1
#include <stdbool.h>
For someone like me here to copy and paste.
Try this header file in your code
stdbool.h
This must work
Source: Stackoverflow.com