Validity/Invalidity of the code

R

Rajesh S R

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.
 
G

Guest

Rajesh said:
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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top