Question about C Struct (from TabOS)
Posted: Wed Mar 03, 2004 8:37 pm
Looking through the TabOS code I came across this neat structure
typedef struct
{
ushort segment_limit_0_15;
ushort base_address_0_15;
uchar base_address_16_23;
unsigned segment_type:4;
unsigned descriptor_type:1;
unsigned dpl:2;
unsigned present:1;
unsigned segment_limit_16_19:4;
unsigned available:1;
unsigned zero:1;
unsigned default_operation_size:1;
unsigned granularity:1;
uchar base_address_24_31;
} NOALIGN segment_descriptor
How is it that he can define variables with no type? Is it a gcc extension or something. I see that the NOALIGN actually is a __attribute__ ((pack)) that specifies the structure should use the minimum amount of space possible. Hence it comes out to 4 words as required, assuming that the untyped unsigned variables are bits. (which fits into how they are defined with the colon: and # of bits to use)
But where is this kind of syntax documented??
Thanks
typedef struct
{
ushort segment_limit_0_15;
ushort base_address_0_15;
uchar base_address_16_23;
unsigned segment_type:4;
unsigned descriptor_type:1;
unsigned dpl:2;
unsigned present:1;
unsigned segment_limit_16_19:4;
unsigned available:1;
unsigned zero:1;
unsigned default_operation_size:1;
unsigned granularity:1;
uchar base_address_24_31;
} NOALIGN segment_descriptor
How is it that he can define variables with no type? Is it a gcc extension or something. I see that the NOALIGN actually is a __attribute__ ((pack)) that specifies the structure should use the minimum amount of space possible. Hence it comes out to 4 words as required, assuming that the untyped unsigned variables are bits. (which fits into how they are defined with the colon: and # of bits to use)
But where is this kind of syntax documented??
Thanks