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.

TMS320F28375D: Address boundary of structure in the several case

Part Number: TMS320F28375D


Our customer would like to know about an address boundary of a structure as shown below.

(1) When declaring a structure variable all of sampleA to sampleF,
what is the address boundary where the entity of the structure is located?
In addition, does a padding occur at the declaration?

2) When declaring a pointer and securing the area of the structure,
what is the address boundary where the entity of the structure is located?


struct sampleA {
long a;
long b;
};

struct sampleB {
short a;
short b;
long c;
long d;
};

struct sampleC {
union {
short a[8];
long b[4];
} c;
};

struct sampleD {
short a:8;
short b:8;
short c;
long d;
};

struct sampleE {
short b;
short c;
struct sampleD a;
long d;
};

struct sampleF {
struct sampleD *pa;
short b;
short c;
long d;
};

Regards,

  • First, you need to understand how the built-in types are aligned.  Structures are aligned to the worst case alignment of any of its members.  

    Yoshita said:
    When declaring a structure variable all of sampleA to sampleF,
    what is the address boundary where the entity of the structure is located?

    Since all of the structures contain at least one long, they are all aligned on a 2-word boundary.

    Yoshita said:
    In addition, does a padding occur at the declaration?

    Padding, within a structure, is possible.  None of the structures you show have any padding.  However, consider this example ...

    struct needs_padding {
        short short_field;
        /* 1-word of padding here */
        long  long_field;
    };

    Yoshita said:
    When declaring a pointer and securing the area of the structure,
    what is the address boundary where the entity of the structure is located?

    Structures which contain a pointer are aligned on a 2-word boundary.

    Thanks and regards,

    -George