Struct issue
-
how to make clear that this struct has to be 2 bytes in size and NOT 3?
typedef struct _TEST
{
USHORT FragmentOffset: 13;
UCHAR MF: 1;
UCHAR DF: 1;
UCHAR Reserved: 1;
} TEST, *PTEST;Thanks Don't try it, just do it! ;-)
-
how to make clear that this struct has to be 2 bytes in size and NOT 3?
typedef struct _TEST
{
USHORT FragmentOffset: 13;
UCHAR MF: 1;
UCHAR DF: 1;
UCHAR Reserved: 1;
} TEST, *PTEST;Thanks Don't try it, just do it! ;-)
Hi, try to sizeof(...) = 4 ;) Vitali http://www.creative-case.com
-
how to make clear that this struct has to be 2 bytes in size and NOT 3?
typedef struct _TEST
{
USHORT FragmentOffset: 13;
UCHAR MF: 1;
UCHAR DF: 1;
UCHAR Reserved: 1;
} TEST, *PTEST;Thanks Don't try it, just do it! ;-)
Use #pragma pack John
-
Use #pragma pack John
I did, but it doesn't work. Don't try it, just do it! ;-)
-
Hi, try to sizeof(...) = 4 ;) Vitali http://www.creative-case.com
I can't, this struct is part of the IPv4 header. Don't try it, just do it! ;-)
-
I did, but it doesn't work. Don't try it, just do it! ;-)
How about making all the UCHARs to USHORT? John
-
How about making all the UCHARs to USHORT? John
Thank you John, that works! Don't try it, just do it! ;-)
-
How about making all the UCHARs to USHORT? John
Yes, you are right. But how strange ... although I remembered that in C++ syntax, we only have to write this way for bit field:
struct SS
{
unsigned A : 13;
unsigned B : 1;
unsigned C : 1;
unsigned D : 1;
}; // size = 4.But with pragma of VisualC++7, the previous acts different to:
struct SS
{
unsigned short A : 13;
unsigned short B : 1;
unsigned short C : 1;
unsigned short D : 1;
}; // size = 2.Maxwell Chen
-
how to make clear that this struct has to be 2 bytes in size and NOT 3?
typedef struct _TEST
{
USHORT FragmentOffset: 13;
UCHAR MF: 1;
UCHAR DF: 1;
UCHAR Reserved: 1;
} TEST, *PTEST;Thanks Don't try it, just do it! ;-)