Article View: comp.sys.acorn.tech
Article #340Re: C query.
From: TMOTA
Date: Thu, 15 Oct 1992 22:05
Date: Thu, 15 Oct 1992 22:05
40 lines
1757 bytes
1757 bytes
banksie@khantazi.welly.gen.nz (Philip R. Banks) writes:
>The problems is thus I have defined a structure like so :-
>typedef struct {
>...
> struct filenode *next;
> struct filenode *prev;
> struct filenode *parent;
> struct filenode *sublist;
>...
>} filenode;
>...
>if ...scratch->next->prev = (struct filenode *) newnode;
I think your problem lies with your use of the word 'struct':
Probably, changing the cast to (filenode *) will be all that is necessary.
This is because now that you have defined 'filenode' as a TYPE you don't
need to use the 'struct' to identify it as a struct.
This may still cause problems (as 'filenode *' may be regarded as a different
type from 'struct filenode *' and thus give an implicit cast error/warning)
For such recursive definitions, I typically use something like:
typedef struct _bob
{
_bob *thingo; /* or possibly 'struct _bob *' ... my memory is dim */
} bob;
... it defines a struct type _bob that you can use in the declaration but
afterwards you use 'bob' everywhere (i.e. bob *mypointer). This should
work fine.
--
_________________ "I'd like to answer this question in two ways:
/____ _ _/_ __ First in my normal voice, and then
// / //_//_ /_/ in a silly, high-pitched whine." (Monty Python)
Technical Details
Message-ID:
<1992Oct15.220541.15667@cs.aukuni.ac.nz>Path:
arc1-ca.pugleaf.net!sparky!uunet!comp.vuw.ac.nz!waikato.ac.nz!aukuni.ac.nz!cs18.cs.aukuni.ac.nz!jwil1References:
<2qdtw7j025n@khantazi.welly.gen.nz>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!comp.vuw.ac.nz!waikato.ac.nz!aukuni.ac.nz!cs18.cs.aukuni.ac.nz!jwil1 Newsgroups: comp.sys.acorn.tech Subject: Re: C query. Message-ID: <1992Oct15.220541.15667@cs.aukuni.ac.nz> From: jwil1@cs.aukuni.ac.nz (TMOTA) Date: Thu, 15 Oct 1992 22:05:41 GMT Sender: jwil1@cs.aukuni.ac.nz (TMOTA) References: <2qdtw7j025n@khantazi.welly.gen.nz> Organization: Computer Science Dept. University of Auckland Lines: 40