structure paddinf : codewarrior compiler

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

structure paddinf : codewarrior compiler

1,047件の閲覧回数
FIDDO
Contributor III

Hi,

I have a doubt in strucure padding relavant to code warrior IDE.  I'm working on a 16 bit microcontroller mc9s12xhy.

typedef struct{

unsigned int x;

unsigned char y;

}Error_mode;

Error_mode Error_mode_Data;

While compiler compiles the code, it shall allocate 4 bytes for Error_mode_Data ( with padding  refernce: .map file ). It doesnt seem to happen. It s allocating 3 bytes only. Hw to switch on/off padding in a code warrior compiler? this is critical coz of im using for EEPROM write/read!

ラベル(1)
0 件の賞賛
返信
1 返信

957件の閲覧回数
Rick_Li
NXP Employee
NXP Employee

Hi,

unsigned char is 1 byte in CodeWarrior for HCS12. so, this struct will take 3 bytes after compiled.

maybe the better way to do that is to define the element y as unsigned int.

If you just want the generated struct is aligned with 2bytes, then, you can also add "ALIGN 2" in the prm file follows the memory address like below:

  EEPROM_00 = READ_ONLY   DATA_FAR IBCC_FAR  0x000800 TO 0x000BFF ALIGN 2;

then, all data in EEPROM_00 will be aligned with 2 bytes.

I hope it helps!

0 件の賞賛
返信