Click here to Skip to main content
15,890,282 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRe: variable of less than a byte Pin
chandu00422-May-08 21:50
chandu00422-May-08 21:50 
AnswerRe: variable of less than a byte Pin
CPallini22-May-08 22:08
mveCPallini22-May-08 22:08 
AnswerRe: variable of less than a byte Pin
ShilpiP22-May-08 22:33
ShilpiP22-May-08 22:33 
GeneralRe: variable of less than a byte Pin
chandu00424-May-08 2:52
chandu00424-May-08 2:52 
AnswerRe: variable of less than a byte Pin
Rajkumar R24-May-08 4:29
Rajkumar R24-May-08 4:29 
AnswerRe: variable of less than a byte Pin
Dan23-May-08 21:48
Dan23-May-08 21:48 
GeneralRe: variable of less than a byte Pin
toxcct22-May-08 23:37
toxcct22-May-08 23:37 
GeneralRe: variable of less than a byte Pin
Rajkumar R23-May-08 0:07
Rajkumar R23-May-08 0:07 
toxcct wrote:
the instanciated structure will be 1 Byte minimum !!!


nope ! minimum size of storage unit depends on machine word length.

The Standard says that fields are packed into ‘storage units’, which are typically machine words. The packing order, and whether or not a bitfield may cross a storage unit boundary, are implementation defined. To force alignment to a storage unit boundary, a zero width field is used before the one that you want to have aligned.

struct MyOneBitStruct {
   unsigned nOneBitMember  : 1;    //  (1 bits)
};

size_t nOneBitStructSize = sizeof(MyOneBitStruct);


run and check the value of nOneBitStructSize, as per your statement it should be sizeof(BYTE) (bitfields other than integer type is not supported by every compiler)

Offcourse, hardware does access to the complete word or individual Byte or individual bit depends on capability, but as far as the variable is language specific (Software part) accessing the variable is managed to the number bits specified in bitfields that is internally managed by compiler. And OPs question variable of less than byte size is answered by bitfields.
GeneralRe: variable of less than a byte Pin
Rajkumar R23-May-08 2:04
Rajkumar R23-May-08 2:04 
AnswerRe: variable of less than a byte Pin
toxcct22-May-08 23:41
toxcct22-May-08 23:41 
GeneralRe: variable of less than a byte Pin
rp_suman24-May-08 2:25
rp_suman24-May-08 2:25 
QuestionCString problem Pin
trioum22-May-08 20:26
trioum22-May-08 20:26 
AnswerRe: CString problem Pin
Cedric Moonen22-May-08 20:37
Cedric Moonen22-May-08 20:37 
GeneralRe: CString problem Pin
trioum22-May-08 20:51
trioum22-May-08 20:51 
GeneralRe: CString problem Pin
Cedric Moonen22-May-08 21:08
Cedric Moonen22-May-08 21:08 
GeneralRe: CString problem Pin
Rajesh R Subramanian22-May-08 21:24
professionalRajesh R Subramanian22-May-08 21:24 
GeneralRe: CString problem Pin
toxcct22-May-08 23:46
toxcct22-May-08 23:46 
GeneralRe: CString problem Pin
Rajesh R Subramanian23-May-08 0:35
professionalRajesh R Subramanian23-May-08 0:35 
GeneralRe: CString problem Pin
Rajesh R Subramanian29-Jul-08 21:18
professionalRajesh R Subramanian29-Jul-08 21:18 
GeneralRe: CString problem Pin
toxcct29-Jul-08 21:22
toxcct29-Jul-08 21:22 
GeneralRe: CString problem Pin
CPallini22-May-08 21:28
mveCPallini22-May-08 21:28 
GeneralRe: CString problem Pin
Cedric Moonen22-May-08 21:42
Cedric Moonen22-May-08 21:42 
GeneralAlways mocking me! Pin
CPallini22-May-08 22:07
mveCPallini22-May-08 22:07 
AnswerRe: CString problem Pin
ShilpiP22-May-08 20:39
ShilpiP22-May-08 20:39 
GeneralRe: CString problem Pin
ShilpiP22-May-08 20:57
ShilpiP22-May-08 20:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.