This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Packed structs in CCE

Hi,

 I have just started playing with CCE 3.0 and have a question regarding packing of C-language structures.

With IAR we use the pragma below to pack a structure, what would the equivalent be using CCE? Without the default settings, CCE insert padding bytes before the 8-bit variables, I want to avoid this.

#ifdef __ICC430__

#pragma pack(1)

#endif

typedef struct {

uint8 packetLength;

uint16 frameControlField;

uint8 seqNumber;

uint16 panId;

uint16 destAddr;

uint16 srcAddr;

#ifdef SECURITY_CCM

uint8 securityControl;

uint32 frameCounter;

#endif

} basicRfPktHdr_t;

#ifdef __ICC430__

#pragma pack()

#endif

  • Hi

     

    Searching the MSP430 Optimizing C/C++ Compiler User's Guide I do not find any reference to the pragma pack directive. So, I think it is not supported (is this true?!)

    I also like to know how to pack a structure with CCE.

     

    Searching the web I find this nice article.

     

    AES

  • After reading the previously article I search and find that we can enable the –gcc compiler option. This option allows us to use the GNU C Compiler Extensions, like specify the attributes of variables. Here you can find useful information about this subject.

    So, after you active the –gcc option (in Properties > C/C++ Build > MSP430 Compiler 3.0 > Runtime Model Option) you will be allowed to make declarations like

     

    int x __attribute__ ((aligned (16))) = 0;

     

    or

     

    short array[3] __attribute__ ((aligned));

     

    Unfortunately, when I try to use the packed keyword compiler tells me that  this is an invalid attribute for field.

     

    AES

  • The TI compilers including the MSP430 compiler in CCE do not support packed structures.
    https://community.ti.com/forums/p/87/119.aspx#119

     

**Attention** This is a public forum