这是迄今为止我所包含的所有.h文件,但没有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>
哪个文件定义bool
?
它是C99的一部分,在POSIX definition stdbool.h中定义。
bool
只是一个扩展到_Bool
的宏。你可以使用没有_Bool
的#include
非常像你可以使用int
或double
;它是一个C99关键字。
该宏在<stdbool.h>
中与其他3个宏一起定义。
定义的宏是
bool
:宏扩大到_Bool
false
:宏扩大到0
true
:宏扩大到1
__bool_true_false_are_defined
:宏扩大到1
#include <stdbool.h>
像我这样的人来复制和粘贴。
布尔运算的头文件n C是stdbool.h
在代码中尝试此头文件
stdbool.h
这必须奏效