View previous topic :: View next topic |
Author |
Message |
Akutabi
Joined: 18 Aug 2006 Posts: 6
|
Use of bit fields |
Posted: Wed Oct 11, 2006 7:55 am |
|
|
Hi,
Is it possible to use bit fields with CCS ?
In C ANSI, bit fields are used like this :
struct {
short x:5, y:4, z:7;
}data;
struct data my_data;
my_data.x = ....
my_data.y = ....
my_data.z = ....
So, is it possible to to do the same with CCS ?
Thanks, |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
|
Posted: Wed Oct 11, 2006 8:13 am |
|
|
Yes. Bit fields are part of standard C (not just ANSI C), and CCS follows the 'norm' with this. However there is a restriction. Since the default data type is an 8 bit integer, the field 'boundaries' have to fit inside this. As shown, it'll fail, since a 5 bit field, plus a 4 bit field, and a 7 bit field will not fit into an 8 bit field.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|