By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,915 Members | 1,268 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,915 IT Pros & Developers. It's quick & easy.

Validity/Invalidity of the code

P: n/a
Can anyone explain the validity/invalidity of the following code as
per the C standards?

struct node
{
int a;
float;/*Declarator without any identifier*/

struct node2;/*a struct tag declaration*/

struct node* ptr;
};

int main( void )
{
int a, b;
double;/*A declarator without any identifier*/
char;/*A declarator without any identifier*/

}
Thanks in advance for the reply.

Mar 24 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Rajesh S R wrote:
Can anyone explain the validity/invalidity of the following code as
per the C standards?
I'm assuming you know they're invalid, so I'll just list the
constraints they violate.
struct node
{
int a;
float;/*Declarator without any identifier*/
^ [1]
struct node2;/*a struct tag declaration*/
^ [1] + [2]
struct node* ptr;
};

int main( void )
{
int a, b;
double;/*A declarator without any identifier*/
^ [3]
char;/*A declarator without any identifier*/
^ [3]
}
Thanks in advance for the reply.
[1] Syntax error: the declarator may be omitted only in bit-fields
(6.7.2.1)
[2] "A structure or union shall not contain a member with incomplete
or function type" (6.7.2.1)
[3] "A declaration shall declare at least a declarator (other than the
parameters of a function or the members of a structure or union), a
tag, or the members of an enumeration." (6.7)

Mar 24 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.