Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/61.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在linux中,在c中使用bool-type时包括哪些头文件?_C_Boolean - Fatal编程技术网

在linux中,在c中使用bool-type时包括哪些头文件?

在linux中,在c中使用bool-type时包括哪些头文件?,c,boolean,C,Boolean,以下是我到目前为止包含的所有.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> #inc

以下是我到目前为止包含的所有.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

它是中的一部分并在中定义。

bool
只是一个扩展到
\u bool
的宏。您可以使用
\u Bool
而不使用
\include
非常像您可以使用
int
double
;这是一个C99关键字

宏与其他3个宏一起在
中定义

定义的宏是

  • bool
    :宏扩展为
    \u bool
  • false
    :宏扩展为
    0
  • true
    :宏扩展为
    1
  • \u bool\u true\u false\u已定义
    :宏扩展为
    1

在代码中尝试此头文件

stdbool.h
这必须有效

#包括


像我这样的人在这里复制和粘贴

tere是POSIX规范的最新版本。我只需像C99之前的每个人一样使用
int
),这只是重复现有的答案。这如何提供比其他5年前的答案更多的信息?@PrafullaKumarSahu它确实提供了一个答案(即使你认为这是低质量的)我注意到有两个答案,只是pmg答案的重复。