From: Damian Yerrick Newsgroups: comp.os.msdos.djgpp Subject: Re: Errors using Bit Fields in DJGPP Organization: Pin Eight Software http://pineight.8m.com/ Message-ID: References: <38BE798A DOT E4C77E32 AT americasm01 DOT nt DOT com> X-Newsreader: Forte Agent 1.7/32.534 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 45 X-Trace: +rhFIpF5IOdv2P6Ov7lfAOWbES6/JV+N335ru+zmROWw6Ma02qzZC0Gb93zCJ0UdwZmEhh0sxZBf!TPL3PCPlFzm0oUNHUcTmPzho4HvsRySwoREB9GkP+UEv/RTlQGppKzsEaELasM2T9mywJFMMf3nU!b8g= X-Complaints-To: abuse AT gte DOT net X-Abuse-Info: Please be sure to forward a copy of ALL headers X-Abuse-Info: Otherwise we will be unable to process your complaint properly NNTP-Posting-Date: Fri, 03 Mar 2000 05:12:01 GMT Distribution: world Date: Fri, 03 Mar 2000 05:12:01 GMT To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com On Thu, 02 Mar 2000 09:24:10 -0500, "Campbell, Rolf [SKY:1U32:EXCH]" wrote: >JoeGuy wrote: > >> Are bit fields possible in DJGPP? I tried the following code and got erros: >> >> unsigned getInput():4 >> { >> unsigned up : 1 = key[KEY_UP]; >> unsigned left : 1 = key[KEY_LEFT]; >> unsigned right : 1 = key[KEY_RIGHT]; >> unsigned down : 1 = key[KEY_DOWN]; >> >> Notice I've tried to return a bit field also, but all get errors: > >Bit fields are only allowed inside a struct/class. So try this: typedef struct NESInputByte { unsigned a:1; unsigned b:1; unsigned select:1; unsigned start:1; unsigned up:1; unsigned down:1; unsigned left:1; unsigned right:1; } NESInputByte; then tossing a NESInputByte wherever you need to track keypresses. But I never use C bitfields; they're too implementation defined. I use enums and bitwise booleans instead. -- Damian Yerrick http://yerricde.tripod.com/ Comment on story ideas: http://home1.gte.net/frodo/quickjot.html AOL is sucks! Find out why: http://anti-aol.org/faqs/aas/ View full sig: http://www.rose-hulman.edu/~yerricde/sig.html This is McAfee VirusScan. Add these two lines to your .sig to prevent the spread of .sig viruses. http://www.mcafee.com/