473,395 Members | 1,702 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Structures and Linked Lists (hopefully a really stupid question)



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
Jan 23 '07 #1
2 1154
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/

Jan 23 '07 #2
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
Jan 23 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Chris Ritchey | last post by:
Hmmm I might scare people away from this one just by the title, or draw people in with a chalange :) I'm writting this program in c++, however I'm using char* instead of the string class, I am...
4
by: Thomas Paul Diffenbach | last post by:
Can anyone point me to an open source library of /statically allocated/ data structures? I'm writing some code that would benefit from trees, preferably self balancing, but on an embedded system...
12
by: Jonathan Bartlett | last post by:
Just finished a new IBM DeveloperWorks article on linked lists, and thought you all might be interested. It's not an introduction -- it instead covers some of the more interesting aspects of...
5
by: JL | last post by:
Hi, I was asked the following question at work: "Assume that you have 5000 columns and 5000 rows of data. You take these data from the database and need to show them in a table. Before...
3
by: valerio | last post by:
Hello all I would like to dinamically allocate an array of array of structures. To explain this: struct file{ char* fileName,int inode) myfiles; struct file{ char* fileName,int inode) mydirs; ...
11
by: efrat | last post by:
Hello, I'm planning to use Python in order to teach a DSA (data structures and algorithms) course in an academic institute. If you could help out with the following questions, I'd sure...
12
by: joshd | last post by:
Hello, Im sorry if this question has been asked before, but I did search before posting and couldnt find an answer to my problem. I have two classes each with corresponding linked lists, list1...
13
by: jehugaleahsa | last post by:
Hello: I got tired of trying to find good implementations of collections and other data structures in C#. So, I started implementing my own. However, data structures is a wholly different...
2
by: Andreas Lundgren | last post by:
Hi! I want to put some values in static memory, and then be able to reference this data from my code in a decent way by referencing AllData.Data. (All code beneth is placed outside functions.) ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.