Structures and Linked Lists (hopefully a really stupid question)

D

Daniel Rudy

Consider the following two code fragments:

Example 1:

typedef struct datatype_tag
{
char section[64];
char name[64];
char value[1024];
datatype_t *next;
} datatype_t;



Example 2:

typedef struct datatype_tag
{
char section[64];
char name[64];
char value[1024];
struct datatype_tag *next;
} datatype_t;



Now the first one generates a syntax error from gcc. The second one
works just fine. Why?

I'm thinking it has to do with me using the typedef'd identifier in the
middle of the typedef declaration? If that's the case, will it be ok
with the second form?



--
Daniel Rudy

Email address has been base64 encoded to reduce spam
Decode email address using b64decode or uudecode -m

Why geeks like computers: look chat date touch grep make unzip
strip view finger mount fcsk more fcsk yes spray umount sleep
 
S

Spiros Bousbouras

Daniel said:
Consider the following two code fragments:

Example 1:

typedef struct datatype_tag
{
char section[64];
char name[64];
char value[1024];
datatype_t *next;
} datatype_t;



Example 2:

typedef struct datatype_tag
{
char section[64];
char name[64];
char value[1024];
struct datatype_tag *next;
} datatype_t;



Now the first one generates a syntax error from gcc. The second one
works just fine. Why?

I'm thinking it has to do with me using the typedef'd identifier in the
middle of the typedef declaration? If that's the case, will it be ok
with the second form?

This is question 1.14 of the FAQ which can be
found at http://c-faq.com/
 
D

Daniel Rudy

At about the time of 1/22/2007 6:42 PM, Spiros Bousbouras stated the
following:
Daniel said:
Consider the following two code fragments:

Example 1:

typedef struct datatype_tag
{
char section[64];
char name[64];
char value[1024];
datatype_t *next;
} datatype_t;



Example 2:

typedef struct datatype_tag
{
char section[64];
char name[64];
char value[1024];
struct datatype_tag *next;
} datatype_t;



Now the first one generates a syntax error from gcc. The second one
works just fine. Why?

I'm thinking it has to do with me using the typedef'd identifier in the
middle of the typedef declaration? If that's the case, will it be ok
with the second form?

This is question 1.14 of the FAQ which can be
found at http://c-faq.com/

I was looking for that. Thank you for the link.


--
Daniel Rudy

Email address has been base64 encoded to reduce spam
Decode email address using b64decode or uudecode -m

Why geeks like computers: look chat date touch grep make unzip
strip view finger mount fcsk more fcsk yes spray umount sleep
 

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

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top