Quote:
Quote:

The data in the ECU and the communication packets are byte-aligned, therefore i've used a pragma to byte-align the structs (only 8 and 16 bit members). Could this cause any problems with gcc and the ARM cpu?



Not if you're doing it right, generally *not* byte-aligning things is what causes problems.

This is true, but "getting it right" is a slippery term: if you know what the C standard guarantees and what it doesn't, you'll be fine, but if you assume that anything which works on x86, also works on ARM, you'll be in great trouble. For instance, the following C exhibits undefined behaviour and does not work on ARM:

Code:
struct foo_t {
short s;
int x;
} __attribute__ ((packed));

int f(struct foo_t *ft)
{
int *p = &(ft->x);
return *p;
}


The assignment to p of an unaligned pointer is undefined, and f will give the wrong answer. If you remove the __attribute__((packed)) then you get valid and working C, but then sizeof(struct foo_t) will be 8, not the 6 one might otherwise expect.

Peter