ARM Technical Support Knowledge Articles

BYTEALIGN DIRECTIVE

Applies to: C166 C Compiler

Answer


Information in this article applies to:


QUESTION

Does the C166 Compiler support pointers to byte-aligned objects?

ANSWER

Yes. This is accomplished with the BYTEALIGN directive.

The BYTEALIGN directive causes the C166 Compiler to generate code that supports structure pointers that may start on byte boundaries. This directive is required when you use the PACK(1) directive.

For example:


#pragma pack(1)     /* byte alignment */
#pragma BYTEALIGN

struct s1  {
  int  i1;       // i1 has offset 0
  char c1;       // c1 has offset 2
  struct s2  {
    int  i2;     // i2 has offset 3
    char c2;     // c2 has offset 5
    int  i3;     // i3 has offset 6
  } s2;
  char z1;       // z1 has offset 8
} s1;

struct s2 *s2p;

void main (void)  {
  s2p = &s1.s2;   // pointer to bytealigned struct
  s2p->i2 = 0;    // access to bytealigned int
}

SEE ALSO

Article last edited on: 2000-09-07 00:00:00

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential