CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Struct question

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Guest








Struct question
PostPosted: Tue Mar 01, 2005 3:45 am     Reply with quote

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







PostPosted: Tue Mar 01, 2005 8:02 am     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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