问题描述
|
这是我到目前为止已包含的所有.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>
哪个文件定义“ 0”?
解决方法
它是C99的一部分,在POSIX定义stdbool.h中定义。
,
#include <stdbool.h>
对于像我这样的人,请在此处复制和粘贴。
,bool
只是扩展为_Bool
的宏。您可以使用_Bool
而不使用#include
,就像您可以使用int
或double
一样;它是一个C99关键字。
宏与其他3个宏一起在<stdbool.h>
中定义。
定义的宏是
bool
:宏扩展为_Bool
false
:宏扩展为0
true
:宏扩展为1
__bool_true_false_are_defined
:宏扩展为1
,在代码中尝试此头文件
stdbool.h
这必须工作