[sdiy] Quick C query

Tom Wiltshire tom at electricdruid.net
Sun Nov 21 14:53:10 CET 2010


Thanks. I usually use bit fields in assembly, and wondered if that was the way to go in C. I think I'd better look at what I get out of the compiler too - I can see potential for something that's intended to be efficient actually making the situation much worse.

T.

On 21 Nov 2010, at 13:37, Thomas Strathmann wrote:

> On 11/21/10 14:31 , Tom Wiltshire wrote:
>> What's the best way to deal with booleans in C? I see that we don't have a Boolean type explicitly.
>> Presumably there's a standard practice for this, since I'm not the first person to need a boolean.
> 
> If you just need one or two boolean variables use something like char which has only 8 bits usually. If you need whole arrays of boolean variables you'll want to look into bit manipulation to adress each bit individually or try out what the compiler does with bit fields.
> 
> I think http://en.wikipedia.org/wiki/Bit_field has a fairly good discussion.
> 
> 	Thomas
> _______________________________________________
> Synth-diy mailing list
> Synth-diy at dropmix.xs4all.nl
> http://dropmix.xs4all.nl/mailman/listinfo/synth-diy




More information about the Synth-diy mailing list