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
-
- Experienced Member
- Posts: 99
- Joined: Sat Aug 31, 2013 11:23 pm
-
- XCore Expert
- Posts: 968
- Joined: Thu Dec 10, 2009 9:20 pm
- Location: Bristol, UK
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.
-
- XCore Expert
- Posts: 844
- Joined: Sun Jul 11, 2010 1:31 am
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?
-
- Experienced Member
- Posts: 99
- Joined: Sat Aug 31, 2013 11:23 pm
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.
-
- Active Member
- Posts: 47
- Joined: Wed Feb 05, 2014 1:25 am
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.
-
- XCore Expert
- Posts: 968
- Joined: Thu Dec 10, 2009 9:20 pm
- Location: Bristol, UK
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.
-
- Member
- Posts: 11
- Joined: Thu Oct 06, 2016 4:58 am
Packed structures would be helpful for me too, for the same reason: being able to represent data coming from outside the system.