AnsweredAssumed Answered

structure data alignment rules (56F8013)

Question asked by Charles Labarre on Apr 20, 2006
Latest reply on Apr 21, 2006 by Charles Labarre

Hi,

 

I'm using a 56F8013 and I would like to control the compiler's boundary rule for structure. In "Targeting_56800E.pdf" at section "Targeting MC56F83xx/DSP5685x Controllers" page 133, it says that "A structure containing only bytes still is word aligned.".

 

The problem is that I'm trying to read an array of single-byte structure and I would really like to use the structure layout in my C code.

 

If I have an array of these then
typedef struct{
unsigned char _someValueA:3;
unsigned char _someValueB:2;
unsigned char _someValueC:1;
unsigned char _someValueD:1;
unsigned char _someValueE:1;
}myStruct;

 

I can't use things like ptr->_someValueC because of code generated forces the boundary of the structure to be word aligned. I need it to be byte aligned. Is there any ways (pragmas, attribute or compiler flags) that I can use my structure in C?

 

Otherwise I have to read them as byte and use explicit shifter which reduce the clarity of the source.

 

I'm using :
Metrowerks C/C++ for DSP M56800E.
Copyright (c)1998-2005, Metrowerks
All rights reserved.
Version 7.2 build 1003
Runtime Built: Apr 15 2005 19:46:26

 

Thanks.

Outcomes