Date: Thu, 02 Oct 2003 12:40:09 -0400 From: Bill Moran <wmoran@potentialtech.com> To: Lowell Gilbert <freebsd-questions-local@be-well.ilk.org> Cc: questions@freebsd.org Subject: Re: [OT] C question (typedef & structs) Message-ID: <3F7C54E9.1030306@potentialtech.com> In-Reply-To: <44isn7r5j2.fsf@be-well.ilk.org> References: <3F7C4A3F.8000508@potentialtech.com> <44isn7r5j2.fsf@be-well.ilk.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Lowell Gilbert wrote:
> Bill Moran <wmoran@potentialtech.com> writes:
>
>
>>1) What's the difference between:
>>
>>struct customStruct {
>> int RecID;
>> char *Name;
>>};
>>
>>and
>>
>>typedef struct customStruct {
>> int RecID;
>> char *Name;
>>};
>>
>>??
>>
>>I had the latter, but when I started moving my code into
>>different files to reorganize things, gcc started giving
>>me warnings. The warnings went away when I moved to the
>>former. I can't quite figure out what the difference is.
>>Is one correct and the other not?
>
> I'm not sure whether the second is illegal or not, but in any case it
> doesn't make any sense
Oddly enough, that's about what the error gcc gave me said.
<snip>
> If you're sticking to strictly ANSI C like this, the comp.lang.c
> newsgroup is a good place to go. More useful is its FAQ, which
> you can find at "http://www.eskimo.com/~scs/C-faq/faq.html". There
> are other newsgroups on C, including one for learners, but I don't
> have the precise name at hand.
Thanks. That's another excellent link!
> A good book might be a better bet, though. Both Kernighan & Ritchie
> and Harbison & Steele have discussions of typedefs that show how to
> use them with structures.
Heh. I'll look into those. The book I have seems good most of the
time, but I wasn't getting a real understanding of typedef from it.
--
Bill Moran
Potential Technologies
http://www.potentialtech.com
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3F7C54E9.1030306>
