Boolean true/false in IRIX C?

KayBee

Member
Feb 24, 2020
80
56
18
Hi Again,

I am converting an Arduino program to Irix C on my O2 and the Arduino uses:
Code:
boolean mycondition = false;
But I cannot yet find the IRIX C equivalent. Would you guys have some ideas here?

Thank you again.

KB
 

KayBee

Member
Feb 24, 2020
80
56
18
Looks like it will be this:

Code:
typedef enum {false, true} boolean;
Cheers,

KB
 

jrra

New member
Apr 13, 2019
1
1
3
Hello @KayBee,

The usual way of using booleans in C is one of the following:
- on C99 and up, you can include <stdbool.h> and use the type 'bool' with values 'ture' or 'false'. This is what Therion's reply, above, is referring to.
- for ANSI C or C89 (same thing) the usual way is to use type 'int' with values of 0 or 1.

I like your typedef/enum trick. It should work fine, as long as you are careful when incorporating code from other projects into your own.

Note that the type 'boolean' is particular to the Wire/Arduino language and is not a part of C or C++. (unless you define it yourself of course)

Hope this helps!
 
  • Like
Reactions: Elf

foetz

Member
Feb 19, 2019
85
41
18
the type 'boolean' is particular to the Wire/Arduino language and is not a part of C or C++.
exactly. that's not c at all and not irix specific. however with typedefs like the ones shown above you can call it whatever you want :)
 

About us

  • Silicon Graphics User Group (SGUG) is a community for users, developers, and admirers of Silicon Graphics (SGI) products. We aim to be a friendly hobbyist community for discussing all aspects of SGIs, including use, software development, the IRIX Operating System, and troubleshooting, as well as facilitating hardware exchange.

User Menu