Re: Size of structs containing unions
- From: Martin Ambuhl <mambuhl@xxxxxxxxxxxxx>
- Date: Fri, 30 Sep 2005 16:09:41 GMT
luke wrote:
hi, in Visula C++ 6.0 I have declared a struct like this:
typedef struct _WRITE_INPUT {
ULONG DeviceNumber; ULONG RegisterNumber; union { USHORT ShortData; UCHAR CharData; }; } WRITE_INPUT;
I can't understand why, sizeof(WRITE_INPUT) returns 12. It should return 10, shouldn't it?
Please check the FAQ before posting. You might find <http://www.eskimo.com/~scs/C-faq/q2.13.html> enlightening.
BTW: Avoid nonstandard typenames in postings. If ULONG, USHORT, and UCHAR are in fact unsigned long, unsigned short, and unsigned char, why not use the real typenames?
.
- References:
- Size of structs containing unions
- From: luke
- Size of structs containing unions
- Prev by Date: Re: size of pointer in C?
- Next by Date: Help with system calls
- Previous by thread: Re: Size of structs containing unions
- Next by thread: performing a "deep copy" on a nested structure
- Index(es):
Relevant Pages
|