CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

struct problem

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
chava



Joined: 07 Sep 2003
Posts: 56

View user's profile Send private message Send e-mail

struct problem
PostPosted: Thu Feb 26, 2004 4:11 am     Reply with quote

Hi
I have a variable which I want to access it's bits
I defined:
Code:
struct {
char b0:1;char b1:1;/*etc..*/}var;

now I want to use
Code:
if (bit_test(var,1)) ...


but the compiler reply with "A numeric expression must appear here"

does someone knows what the problem is?
Guest








PostPosted: Thu Feb 26, 2004 10:04 am     Reply with quote

First off I think you are defining a structure containing characters not bits.

struct
{

unsigned b0: 1; // try this

short b1; // or this

} var;

Now try

if ( var.b0 )

Hope this helps.

Doug
Douglas Richard



Joined: 08 Sep 2003
Posts: 49
Location: Concord NH

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Thu Feb 26, 2004 10:07 am     Reply with quote

Sorry I was not logged in when I responded before.

Doug
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group