# Bool

Status
Not open for further replies.

#### be80be

##### Well-Known Member
How would one write this in xc8
Code:
bool read_SCL(void);

#### be80be

##### Well-Known Member
I tried that it saying it can't find the .h file include <stdbool.h>

#### be80be

##### Well-Known Member
Ian I no it's in there when I try to use it I get error that it can't be found.

You know I don't mean this in a mean way but I seen people post and get all kind of help I'm not a C programmer I don't no it all but I googled for 2 days. And this is about all I found about boolen
It's Not really for c It can be used if you add the #include "stdbool.h"
Which I did
Code:
#include "xc.h"
#include "stdbool.h"
#include "GenericTypeDefs.h"

#include "boolType.h"
#define I2CSPEED 100

void I2C_delay(void);
BOOL read_SCL(void);  // Return current level of SCL line, 0 or 1
BOOL read_SDA(void);  // Return current level of SDA line, 0 or 1
void set_SCL(void);   // Do not drive SCL (set pin high-impedance)
void clear_SCL(void); // Actively drive SCL signal low
void set_SDA(void);   // Do not drive SDA (set pin high-impedance)
void clear_SDA(void); // Actively drive SDA signal low
void arbitration_lost(void);
I get a bucket load of these
C:/Users/USER/Desktop/Clearning/bitbang/bitbang.X/main.c:81: warning: (374) missing basic type; int assumed
I can change to a .cpp C++ and I can use them.
But bool is being used a type of int to just check if I'm getting a 0 or 1 bit for ack on the scl line .
I found this code from microchip sample and some reason mplab x 3.65 or 4.00 dosen't like bool at all.

Last edited:

#### Ian Rogers

##### User Extraordinaire
Forum Supporter
C:
#include "xc.h"
#include "stdbool.h"
#include "GenericTypeDefs.h"

#include "boolType.h"
All wrong!!
Use...
C:
#include <xc.h>
#include <stdbool.h>
#include <GenericTypeDefs.h>

#include <boolType.h>
Quotes "" are for working directory and triangular braces <> are for the compiler directory..

#### be80be

##### Well-Known Member
I Be leave you but It still not right I did it both ways " " and < > get the same bull it can't even find xc.h

I guess I need write a BOOL
Like
Code:
int BOOL;
int bool;
int false;
false== 0;
int true;
true==1;
BOOL== bool;
If  (BOOL=1){
return (true)
}
else if (BOOL=0){
return (false)
But I don't think this is the right way cause the code is testing false or true

Last edited:

#### be80be

##### Well-Known Member
Let's say I do it this way
#define bool int
#define true 1
#define false 0
I need BOOL and bool to be the same BOOL is the function name
where as bool is just a test

#### be80be

##### Well-Known Member
I think I figured why
#include <xc.h>
#include <stdbool.h>
Was not working I was using the plib and to get that to work I had to point to where they where
Then when I went to play with this i2c code it's still pointing to plib folder.
So now it cant find the files as it should I reset the compiler path and what not back to default and it's using it now.

Status
Not open for further replies.