[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] GCC native bool compile on mega8
From: |
Ned Konz |
Subject: |
Re: [avr-gcc-list] GCC native bool compile on mega8 |
Date: |
Wed, 12 Jan 2005 22:51:57 -0800 |
User-agent: |
KMail/1.7.1 |
On Wednesday 12 January 2005 10:33 pm, A Day wrote:
> What does the AVR-GCC compile bools down to? It would be great if a
> bool compiled down to a single bit, but I suspect bools actually take
> up a full byte. I couldn't find this in the FAQ. Thanks ahead of time
> for your insight :-)
Depends on how you define a bool.
If you define it as something int-ish or pass it to a function or do math with
it, it becomes an int. That's C, not GCC.
There's nothing keeping you from defining multiple boolean flags in a single
byte, though:
typedef struct {
uint8_t bool0: 1;
uint8_t bool1: 1;
uint8_t bool2: 1;
uint8_t bool3: 1;
uint8_t bool4: 1;
uint8_t bool5: 1;
uint8_t bool6: 1;
uint8_t bool7: 1;
} eightBool_t;
#define true 1
#define false 0
eightBool_t someBools = { true, false, false, true, false, true, false,
false };
/* but ... */
someFunction(someBools.bool4); /* promotes to an int */
--
Ned Konz
http://bike-nomad.com