Question

I'm currently working on an implementation of a doubly linked list (teaching myself c in preparation for the arrival of my rasp-pi!), and i'v encountered an odd error message. NetBeans doesn't seem to recognize the boolean data-type. What's strange is that i can implement booleans in both of the other classes in the project (main.c & dLinkedList.h). So far i've tried re-installing & updating cygwin (did not resolve the problem). I'll attach some screen shots below.

boolean test in main.c

enter image description here

boolean test in dLinkedList Header

enter image description here

boolean test in dLinkedList.c

enter image description here

Additionally, both my main.c and dLinkedList.c contain the following headers:

#include <stdlib.h>
#include"dll.h"

Any insights would be tremendously appreciated!

Was it helpful?

Solution 2

In C99 you need to include stdbool.h, from the draft C99 standard section 7.16 Boolean type and values says:

1 The header defines four macros.

2 The macro

bool

expands to _Bool.

If C99 is not supported then you need to define your own bool, for example:

#define bool int
#define true 1
#define false 0

OTHER TIPS

If you are using C, include stdbool.h to get the bool macro. However this header only exists if you are using C99 or greater.

As far as I know, in C you have three options:

Defines:

typedef int bool;
#define true 1
#define false 0

Enumerations:

typedef enum 
{ 
    false, 
    true 
}bool;

Add C99 header:

#include <stdbool.h>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top