Error description
unknown type name ‘bool’
Recently, using C to implement data structure encountered the following error
➜ LinkedList gcc list.c
list.c:14:1: error: unknown type name ‘bool’; did you mean ‘_Bool’?
bool is_empty(PNODE pHead);
^~~~
_Bool
list.c:77:1: error: unknown type name ‘bool’; did you mean ‘_Bool’?
bool is_empty(PNODE pHead)
^~~~
_Bool
list.c: In function ‘is_empty’:
list.c:80:9: error: ‘true’ undeclared (first use in this function); did you mean ‘free’?
return true;
^~~~
free
list.c:80:9: note: each undeclared identifier is reported only once for each function it appears in
list.c:82:9: error: ‘false’ undeclared (first use in this function); did you mean ‘fclose’?
return false;
^~~~~
Error reason
Unknown type name: ‘bool’, because there is no boolean type defined in the C language standard (C89), an error will be reported. C99 provides a header file & lt; stdbool.h> Code> defines
bool
, true
represents 1 and false
represents 0. As long as you import stdpool. H
, you can easily operate Boolean types.
resolvent
#include <stdbool.h>
"21442;" 32771;"38142;" 25509
https://www.jianshu.com/p/aa951e784e96