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 CCS Technical Support

Error with #byte and struct

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







Error with #byte and struct
PostPosted: Wed Jun 01, 2005 10:28 pm     Reply with quote

The following is giving me an error on my P18F2680/4680 device. Anyone have a solution?

union {
struct {
int1 FILHIT0:1;
int1 FILHIT1:1;
int1 FILHIT2:1;
int1 FILHIT3:1;
int1 FILHIT4:1;
int1 RTRRO :1;
int1 RXM1 :1;
int1 RXFUL :1;
};
struct {
int1 TXPRI0:1;
int1 TXPRI1:1;
int1 RTREN :1;
int1 TXREQ :1;
int1 TXERR :1;
int1 TXLARB:1;
int1 TXABT :1;
int1 TXBIF :1;
};
} B1CON;
#BYTE B1CON=0xE30

Thanks

Mike
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jun 01, 2005 10:39 pm     Reply with quote

It might be helpful if you told us what compiler version you have
and what error message you're getting -- just so we're working
on the same problem.
Ttelmah
Guest







PostPosted: Thu Jun 02, 2005 2:56 am     Reply with quote

One comment. You are not assigning names to the union sub-parts. The individual structures in a union, must have names, or they can never be accessed. So:
[code]
union {
struct {
int1 FILHIT0:1;
int1 FILHIT1:1;
int1 FILHIT2:1;
int1 FILHIT3:1;
int1 FILHIT4:1;
int1 RTRRO :1;
int1 RXM1 :1;
int1 RXFUL :1;
}A;
struct {
int1 TXPRI0:1;
int1 TXPRI1:1;
int1 RTREN :1;
int1 TXREQ :1;
int1 TXERR :1;
int1 TXLARB:1;
int1 TXABT :1;
int1 TXBIF :1;
}B;
} B1CON;

Would then allow the bits to be accessed as B1CON.A.RXFUL etc.
As it stands, the union definition, contains two structure 'descriptions', but no actual structure defintions, and as such has no size.
Just about any C will complain about this.

Best Wishes
mike holeton
Guest







PostPosted: Thu Jun 02, 2005 10:19 am     Reply with quote

Thanks for the advice. I'm not so sure at the moment that names will solve all of the problem. I'm using the CCS IDE environment and version 3.225.
Guest








PostPosted: Thu Jun 02, 2005 10:22 am     Reply with quote

Also what I'm trying to do is asign names to bits in the structs under the union for the different modes in the special registers. It makes it easier to write and keep track of the modes and bits.
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