From owner-freebsd-questions@FreeBSD.ORG Thu Oct 2 09:03:16 2003 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2B6B016A4B3 for ; Thu, 2 Oct 2003 09:03:16 -0700 (PDT) Received: from be-well.ilk.org (lowellg.ne.client2.attbi.com [66.30.200.37]) by mx1.FreeBSD.org (Postfix) with ESMTP id A004643F93 for ; Thu, 2 Oct 2003 09:03:14 -0700 (PDT) (envelope-from freebsd-questions-local@be-well.ilk.org) Received: by be-well.ilk.org (Postfix, from userid 1147) id 2D5FC3AF4; Thu, 2 Oct 2003 12:03:14 -0400 (EDT) Sender: lowell@be-well.ilk.org To: Bill Moran References: <3F7C4A3F.8000508@potentialtech.com> From: Lowell Gilbert Date: 02 Oct 2003 12:03:13 -0400 In-Reply-To: <3F7C4A3F.8000508@potentialtech.com> Message-ID: <44isn7r5j2.fsf@be-well.ilk.org> Lines: 56 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii cc: questions@freebsd.org Subject: Re: [OT] C question (typedef & structs) X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Oct 2003 16:03:16 -0000 Bill Moran 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 (so I can't be bothered to look it up). In both cases, customStruct is the *structure* tag, not a type name. If you wanted to use a typedef, it would be more like: typedef struct customStruct { int RecID; char *Name; } customType; > 2) I'm a self-taught C programmer. That means that I know > a lot, but I often bump into things that I should know > (like question #1) that I don't. Does anyone have a > suggestion for a mailing list that would be good for > asking questions like the above? Keep in mind that > I'm not an amature, I'm just not formally trained, so > I bump into lots of areas that I'm not sure what I'm > doing because I haven't studied it yet ;) 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. 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. Good luck.