bit-fields in C
Posted: Tue Jun 28, 2005 11:00 pm
hi,
i want to make use of bit-fields to store contents of ecx register to test individual bits,to verify which fetures are supported by processor after 'cpuid' has been executed.
i declare by bit fields in a structure as follows :
struct StandardFeatures1
{
unsigned SSE3Support:1; //SSE3 Support available if set.
unsigned :12; //Reserved bits 12.
unsigned CMPXCHG16B:1; //CMPXCHG16B Instruction support available if set.
unsigned :18; //Reserved bits 18.
};
and then i use this structure in another structure (nested structures) as follows :
/*Stores Processor Information*/
struct ProcessorInfo
{
unsigned int MaxFuncNumber;
unsigned int Stepping,Family,Model,ExtendedFamily,ExtendedModel;
unsigned int EffectiveFamily,EffectiveModel;
unsigned int BrandID,CLFLUSHSize,LogicalMPCount,APICID;
*******ERROR STATEMENT********************
struct StandardFeatures1 StdFeatures1;
***********************************************
char CPUIDSupport,AMDPresent,IntelPresent;
char ProcessorVendor[13];
};
i have declared these structures in a header file. when i compile my source i get following error message :
KLoader.h:12: error: field `StdFeatures1' has incomplete type
my compile options are :
gcc -o KLoader.o -c KLoader.c -Wall -Werror -W --no-warn -nostdlib -nostartfiles -nodefaultlibs
What prob does compiler has? Such structure nesting is allowed in Standard C! (c99)
i want to make use of bit-fields to store contents of ecx register to test individual bits,to verify which fetures are supported by processor after 'cpuid' has been executed.
i declare by bit fields in a structure as follows :
struct StandardFeatures1
{
unsigned SSE3Support:1; //SSE3 Support available if set.
unsigned :12; //Reserved bits 12.
unsigned CMPXCHG16B:1; //CMPXCHG16B Instruction support available if set.
unsigned :18; //Reserved bits 18.
};
and then i use this structure in another structure (nested structures) as follows :
/*Stores Processor Information*/
struct ProcessorInfo
{
unsigned int MaxFuncNumber;
unsigned int Stepping,Family,Model,ExtendedFamily,ExtendedModel;
unsigned int EffectiveFamily,EffectiveModel;
unsigned int BrandID,CLFLUSHSize,LogicalMPCount,APICID;
*******ERROR STATEMENT********************
struct StandardFeatures1 StdFeatures1;
***********************************************
char CPUIDSupport,AMDPresent,IntelPresent;
char ProcessorVendor[13];
};
i have declared these structures in a header file. when i compile my source i get following error message :
KLoader.h:12: error: field `StdFeatures1' has incomplete type
my compile options are :
gcc -o KLoader.o -c KLoader.c -Wall -Werror -W --no-warn -nostdlib -nostartfiles -nodefaultlibs
What prob does compiler has? Such structure nesting is allowed in Standard C! (c99)