Home arrow Forums
OSDEV Forums  


anonymous
Visitor

Fresh Osdever
Posts: 0
graphgraph
Karma: 0  
bit-fields in C - 2005/06/29 05:45 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)
  | | The administrator has disabled public write access.
OSDEV
Community
Advertisement
   
deadmutex
User

Junior Osdever
Posts: 7
graphgraph
Karma: 0  
Re: bit-fields in C - 2005/07/05 21:19
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.
};


you should try something like this instead:

struct StandardFeatures1
{
unsigned SSE3Support:1; //SSE3 Support available if set.
unsigned RESD12:12; //Reserved bits 12.
unsigned CMPXCHG16B:1; //CMPXCHG16B Instruction support available if set.
unsigned RESD18:18; //Reserved bits 18.
};
  | | The administrator has disabled public write access.

A WebArticles site. Sponsored by Evoleto. Motorola V525 / Business Directory / Delaware Incorporation / Home Made Bazaar