bit-fields

Technical questions regarding the XTC tools and programming with XMOS.
Post Reply
DemoniacMilk
XCore Addict
Posts: 191
Joined: Tue Jul 05, 2016 2:19 pm

bit-fields

Post by DemoniacMilk »

I am porting an old project to an xmos device. The old devices configuration was stored in a bit field that is sent to another processor on startup. I would like to keep the bit-fields as they are (so I can recycle some of the old code and do not need additional processing when sending or receiving data when communicating with previous versions), but simply copying the structs from the old project leads to compilation errors:
../src\Modem.h:23:37: error: parse error before ':' token
unsigned int uiTestsignalType : 5;
I read that bit-fields are not supported in xC, what would be an explanation. Howerver, the XS1 Data types the manual says
The types char, short and int may be specified in a bit-field’s declaration.
while this document says
XC does not support floating point, long long arithmetic, structure bit-fields [..]
but then again i remember seeing MKMSK (or something similar) in ASM files, what seems to be well suited for bit fields.
What is correct and how do I define a bit field without compiler complaints?


Gothmag
XCore Addict
Posts: 129
Joined: Wed May 11, 2016 3:50 pm

Post by Gothmag »

I think the documents are not quite up to date. long long and float are supported, bit fields still arent though. I believe the way around this is to just write whatever needs bit fields in c/c++ and use it that way. If you want xc though just do it the old way using & | ^ ~. Will need to modify the bit field areas but shouldn't be too bad.
DemoniacMilk
XCore Addict
Posts: 191
Joined: Tue Jul 05, 2016 2:19 pm

Post by DemoniacMilk »

Okay thank you, I'll go with a classical approach then, although its not very handy.
Post Reply