[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-gcc-list] Re: External EEPROM verses internal EEPROM data handling

From: David Brown
Subject: [avr-gcc-list] Re: External EEPROM verses internal EEPROM data handling
Date: Mon, 04 May 2009 15:42:18 +0200
User-agent: Thunderbird (Windows/20090302)

Daniel O'Connor wrote:
On Mon, 4 May 2009, Bob Paddock wrote:
               uint16_t voltage[24];   // adc counts of 24 channels
in an array } ED;           // total data = 58 bytes
Because of issues of structure packing it is better to define
structure items from
the largest to the smallest, ie. uint16_t should be first.  This is
more important
on 32bit processors and up than on the 8bit AVRs.

You could just mark the struct as packed, eg..
typedef struct eventdata {
} __attribute__ ((packed)) ED;

Or use the -wpadded warning flag, which will let you know if any implicit padding has been added (I prefer to explicitly add padding if it is required).

Of course, you don't get padding on an 8-bit AVR (except for bit fields), but it's good to write portable code when practical.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]