Article View: comp.sys.acorn.tech
Article #363Re: C query.
From: Andy Duplain
Date: Fri, 16 Oct 1992 13:50
Date: Fri, 16 Oct 1992 13:50
44 lines
2009 bytes
2009 bytes
In article <1992Oct16.094939.11437@waikato.ac.nz> banksie@khantazi.welly.gen.nz writes:
>Philip R. Banks writes:
>> Okay here is a little wee problem I am hoping some C type can answer for
>> me. Quickly please, before I take to this compiler with a blunt
>> instrument... :)
>>
>> The problems is thus I have defined a structure like so :-
>>
>> typedef struct {
>> char *name;
>> char *comment;
>> struct filenode *next;
>> struct filenode *prev;
>> struct filenode *parent;
>> struct filenode *sublist;
>> int load;
>> int exec;
>> int length;
>> char flag;
>> } filenode;
>
>Hmm. Well, I can see problems already! The type name 'filenode' isn't defined
>within the structure definition! It's not defined until the end of the typedef
>has been reached.
Well he isn't referencing "type name filenode" from within the
structure definition. The compiler will not complain at this
stage because it knows how big the pointer to structure is, which
is the same as pointer to anything, i.e. 1 word. Philip is getting
confused between structs and typedef names and this can be made
more obvious by doing:
struct filenode {
blah... blah... blah
};
typedef struct filenode *FileNode;
--
Andy Duplain, BT Customer Systems, Brighton, UK. duplain@rtf.bt.co.uk
#define DISCLAIMER My views and opinions are my own, and not my company's
Technical Details
Message-ID:
<1992Oct16.135009.1901@rtf.bt.co.uk>Path:
arc1-ca.pugleaf.net!sparky!uunet!kithrup!hoptoad!pacbell.com!iggy.GW.Vitalink.COM!cs.widener.edu!ukma!darwin.sura.net!paladin.american.edu!news.univie.ac.at!hp4at!mcsun!uknet!axion!rtf.bt.co.uk!duplainReferences:
<2qdtw7j025n@khantazi.welly.gen.nz> <1992Oct16.094939.11437@waikato.ac.nz>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!kithrup!hoptoad!pacbell.com!iggy.GW.Vitalink.COM!cs.widener.edu!ukma!darwin.sura.net!paladin.american.edu!news.univie.ac.at!hp4at!mcsun!uknet!axion!rtf.bt.co.uk!duplain From: duplain@rtf.bt.co.uk (Andy Duplain) Newsgroups: comp.sys.acorn.tech Subject: Re: C query. Keywords: C, typedef, struct, self Message-ID: <1992Oct16.135009.1901@rtf.bt.co.uk> Date: 16 Oct 92 13:50:09 GMT References: <2qdtw7j025n@khantazi.welly.gen.nz> <1992Oct16.094939.11437@waikato.ac.nz> Organization: BT Customer Systems, Brighton, UK Lines: 44