Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Structures and Linked Lists (hopefully a really stupid question)

Reply
Thread Tools

Structures and Linked Lists (hopefully a really stupid question)

 
 
Daniel Rudy
Guest
Posts: n/a
 
      01-23-2007


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
 
Reply With Quote
 
 
 
 
Spiros Bousbouras
Guest
Posts: n/a
 
      01-23-2007
Daniel Rudy wrote:
> 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/

 
Reply With Quote
 
 
 
 
Daniel Rudy
Guest
Posts: n/a
 
      01-23-2007
At about the time of 1/22/2007 6:42 PM, Spiros Bousbouras stated the
following:
> Daniel Rudy wrote:
>> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
structures, structures and more structures (questions about nestedstructures) Alfonso Morra C Programming 11 09-24-2005 07:42 PM
Stupid question. Please, only stupid responders. If you're not sureif you're stupid, you probably aren't. =?ISO-8859-1?Q?R=F4g=EAr?= Computer Support 6 07-18-2005 05:11 AM
stupid stupid stupid kpg MCSE 17 11-26-2004 02:59 PM
Generating a char* from a linked list of linked lists Chris Ritchey C++ 7 07-10-2003 10:12 PM
Generating a char* from a linked list of linked lists Chris Ritchey C Programming 7 07-10-2003 10:12 PM



Advertisments