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.

Packing structures in MSP430 with CCS4.x



Hello,

I have a question related to CCS version 4.x.  My question is about packing structures. 

 In IAR, you just do:

#pragma pack(1)

typedef struct

{

            UINT mychar;

} mystruct;

#pragma pack()

 

In GCC, you do it like this

typedef struct

{

            UINT mychar;

}__attribute__ ((__packed__)) mystruct;

 

Do you know how you pack a structure in the CCS v4.x?

Is this possible?

Also, is this supported in Stellaris and/or C2000?

Thanks again!

Paul

  • The GCC packed attribute is supported in v4.6.x and higher ARM code generation tools (for Stellaris Cortex M3) . CCS v4.1.0 and higher include versions of the compiler that have this support for Stellaris.

    It is currently not supported for MSP430 and C2000, but I expect future releases will. Please check this post for some additional information on upcoming support.

  • With mspgcc, the __attribute((__packed))  is available.

    It does, however, force the compiler to do all acceses to struct members as byte accesses, since the compiler cannot know whether they are still aligned (e.g. in an array, they structs itself could be aligned/misaligned/aligned...). This makes the code less efficient, so it should only be used where absolutely necessary.

    mspgcc is, however, not entirely sourcecode compatible to IAR or CSS.

  • Has there been any action on #pragma pack() support?  I see this was a year ago, and the linked post almost a year before that gave a 6-12-month time frame.  I could really use #pragma pack() today.


    Thanks,

    Chris

**Attention** This is a public forum