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

Missing compiler error?

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



Joined: 13 May 2004
Posts: 90
Location: Nashville, TN

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

Missing compiler error?
PostPosted: Tue Sep 28, 2004 10:21 am     Reply with quote

Why doesn't this produce an error, or at least a warning? As far as I can tell, this declaration has no meaning and can't be accessed. I'm not even totally sure it's well-formed C.

Code:
#include <18F2320.h>

struct {
   int1 element1;
   int1 element2;
   int1 element3;
};

void main() {
}


--
Jeff S.
Guest








PostPosted: Tue Sep 28, 2004 10:52 am     Reply with quote

It is absolutely correct. Your declaration is an anonym structure. It is commonly used in C e.g. in typedefs:

typedef stuct { // the struct has no name
int1 element1;
int1 element2;
int1 element3;
} myrec; // myrec is the name of the new type

The named version looks like this:
typedef stuct _tagMYREC { // tagMYREC is the name of the struct
int1 element1;
int1 element2;
int1 element3;
} myrec; // myrec is the name of the new type
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