Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

RE: [AVR-Chat] Struct ?

2006-06-04 by Larry Barello

Bitfields are probably the MOST non-portable code one can write.  I found
that out the hard way :)  That is why they are discouraged.  Much better to
do the shift & masking manually.  The problem goes beyond big & little
endian: apparently different compilers for the same architecture can
implement bitfields differently!

I didn't want to get into that for Kathy's problem.  The compiler she
mentioned doesn't even use standard (aka portable) constructs for bit
access, so who cares if she wrote even more non-portable code by using
bitfields?  

Cheers!
-----Original Message-----
From: AVR-Chat@yahoogroups.com [mailto:AVR-Chat@yahoogroups.com] On Behalf
Of Colin Paul Gloster
...

On Sat, 3 Jun 2006, Larry Barello wrote an example with bitfields. 
Bitfields provide better protection against accidentally accessing 
irrelevant bits but are discouraged by some, consult e.g. Kernighan, B. W. 
and Ritchie, D. M.: 1988, "The C Programming Language", 2nd edn, Prentice 
Hall, ISBN 0131103628; Gloster, Colin Paul, ``Re: C question'', 27
   Jul 2005 14:55:15 +0200,
Message-ID: <86hdegtnm4.fsf@Delta-Utec_PC5_FreeBSD.lan> ,
news:comp.arch.embedded
...

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.