View previous topic :: View next topic |
Author |
Message |
Guest
|
Struct question |
Posted: Tue Mar 01, 2005 3:45 am |
|
|
HEllo,
///////// Prototipe
Read_pos(); // Can it return 2bit only ,if true , how ?
Code: |
struct Service
{
int Pos: 2;
boolean not used;
boolean not used;
boolean not used;
boolean not used;
boolean not used;
boolean not used;
} Srv;
................
srv.Pos =Read_pos();
|
|
|
|
Ttelmah Guest
|
|
Posted: Tue Mar 01, 2005 8:02 am |
|
|
Just return an integer. The compiler (should) truncate it to fit.
Bit fields, are always 'contained' in a larger carrier type (in the case of CCS, an int8, or char type). Hence even if you can declare the smaller type for the return, the result is the whole 'carrier' being returned, and then truncated to fit the location. Hence there is no advantage in returning the smaller type.
Best Wishes |
|
|
|
|
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
|