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.

#Pragma pack in code composer



Hi,

I wonder how I can achieve the aligning of a stucture definition in Code Composer.

#pragma packed(1)

struct x

{

..variables..

};

The upper code block doesn't work because pragma packed gives a warning of unrecognized pragma.

Thanks in advance,

A. Erman Kulunyar

  • #pragma packed is not listed in the supported pragmas shown in section 6.8 of SPRU187o, I do not know of plans to have a #pragma pack in the C6x CGT set.

    If you just want to align the structure you can use the STRUCT_ALIGN pragma discussed in SPRU187o, so you would have something like #pragma STRUCT_ALIGN( x, 128); which would align x on an 128 byte boundary.

  • The document says, alignment has to be power of 2.

    Considering 2power0 is 1. STRUCT_ALIGN(x, 1) is allowed.

    Does all TI DSPs/Compilers (6000, 5000 and 2000) support alignment of 1?

  • Bhaskar Reddy said:

    The document says, alignment has to be power of 2.

    Considering 2power0 is 1. STRUCT_ALIGN(x, 1) is allowed.

    I suppose this would be allowed but I am not sure that it would really do anything since the smallest addressable unit is a byte and the alignment value there is a byte, so alignment of 1 would imply no special alignment, or perhaps I am missing your intent?

    Bhaskar Reddy said:
    Does all TI DSPs/Compilers (6000, 5000 and 2000) support alignment of 1?

    I mainly only work with the C6x DSPs, but I believe STRUCT_ALIGN is only for C6000 (a quick look in the other compiler manuals and it does not appear to exist).