UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Explorer
Explorer
2,847 Views
Registered: ‎07-25-2016

defining boolean variables in SDK

Hi there,

I have a silly question here..Is it possible to define boolean variables in SDK?

 

Thanks

0 Kudos
3 Replies
Adventurer
Adventurer
2,829 Views
Registered: ‎11-09-2016

Re: defining boolean variables in SDK

You can try stdbool.h library as true or false values with bool variables. Some compiler supports this library.Or 

Define true 1

define false 0

 

 

0 Kudos
Teacher muzaffer
Teacher
2,826 Views
Registered: ‎03-31-2012

Re: defining boolean variables in SDK

@sai_shashi not sure if bool has been added to C but you can just use it with C++.

Anyway most processors have no bit support so a bool has to map to char. You can just do this:

 

typedef unsigned char bool;

const bool TRUE = 1;

const bool FALSE = 0;

 

 

- Please mark the Answer as "Accept as solution" if information provided is helpful.
Give Kudos to a post which you think is helpful and reply oriented.
0 Kudos
Scholar ronnywebers
Scholar
972 Views
Registered: ‎10-10-2014

Re: defining boolean variables in SDK

C99 introduced _Bool to represent Boolean truth variables

_Bool is actually an unsigned integer type

true is coded as '1', false is coded as '0'

 

C99 also added 'stdbool.h' , if you include this header file, you can use :

  • the macro 'bool', which is a synonym to _Bool
  • 'true' which is a constant '1'
  • 'false'  which is a constant '0'

most people use 'bool' instead of _Bool 

 

if you check the stdbool.h in SDK :

 

stdbool.jpg

 

so ... just include 'stdbool.h'

** kudo if the answer was helpful. Accept as solution if your question is answered **
0 Kudos