Hello,
how do I pack a structure in xc?
I am trying to use __attribute__((packed)) , but compiler complains about unrecognized attribute.
Gennady
packed structure in xc
Sadly this is not currently support in XC (though I am campaigning for it ;) )
It is supported in C if that helps.
It is supported in C if that helps.
I have a hard time coming up with an example where "packed"
would be really useful on xcore chips: the memory is too
small for easy memory savings to matter, the cost of unaligned
accesses is much too big.
There is of course legacy code that uses "packed" (or struct
layout in general) to interface to something external. Bad plan.
Do you have an example where it is really useful?
would be really useful on xcore chips: the memory is too
small for easy memory savings to matter, the cost of unaligned
accesses is much too big.
There is of course legacy code that uses "packed" (or struct
layout in general) to interface to something external. Bad plan.
Do you have an example where it is really useful?
I have a profile (structure of application properties), which is loaded externally though HID.
This profile structure is generated externally, on a PC.
On upload profile is stored on a flash (secondary, not boot flash).
On power-up the application loads profile from a flash and operates on it.
From my point of view the easiest way to make sure that alignment is the same in both loaded and internal structures is to have them packed.
This profile structure is generated externally, on a PC.
On upload profile is stored on a flash (secondary, not boot flash).
On power-up the application loads profile from a flash and operates on it.
From my point of view the easiest way to make sure that alignment is the same in both loaded and internal structures is to have them packed.
It is helpful in serial communications.
-
- Experienced Member
- Posts: 94
- Joined: Sun Feb 10, 2013 4:47 am
Hopefully, XMOS will fix this and allow packed structures.
When one receives a serial stream from outside the system, one can't expect the elements are grouped nicely for xmos.
I don't want to be a human compiler piecing bytes together to form the values, when the compiler should be doing it.
And I don't want to write C helper functions either, which are ugly and tedious.
When one receives a serial stream from outside the system, one can't expect the elements are grouped nicely for xmos.
I don't want to be a human compiler piecing bytes together to form the values, when the compiler should be doing it.
And I don't want to write C helper functions either, which are ugly and tedious.
Fair comments..babazaroni wrote:Hopefully, XMOS will fix this and allow packed structures.
When one receives a serial stream from outside the system, one can't expect the elements are grouped nicely for xmos.
I don't want to be a human compiler piecing bytes together to form the values, when the compiler should be doing it.
And I don't want to write C helper functions either, which are ugly and tedious.
Packed structures would be helpful for me too, for the same reason: being able to represent data coming from outside the system.