Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which header file do you include to use bool type in c in linux?

Tags:

c

boolean

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?

like image 866
DriverBoy Avatar asked May 25 '11 02:05

DriverBoy


People also ask

Where is bool defined in Linux?

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.

What library includes bool in C?

A boolean is a data type in the C Standard Library which can store true or false . Every non-zero value corresponds to true while 0 corresponds to false . The boolean works as it does in C++. However, if you don't include the header file​ stdbool.

What data type is bool in C?

In C, Boolean is a data type that contains two types of values, i.e., 0 and 1. Basically, the bool type value represents two types of behavior, either true or false. Here, '0' represents false value, while '1' represents true value.

Can we use bool in C?

In C there is no predefined datatype as bool. We can create bool using enum. One enum will be created as bool, then put the false, and true as the element of the enum.


1 Answers

It's part of C99 and defined in POSIX definition stdbool.h.

like image 53
rlc Avatar answered Sep 22 '22 02:09

rlc