• Welcome to Valhalla Legends Archive.
 

Struct as member of itself?

Started by shadypalm88, December 19, 2004, 09:47 PM

Previous topic - Next topic

shadypalm88

I'm trying to get a pointer to a (typedef'd) struct inside itself.  I know that the addrinfo struct does it (albeit not typedef'd), but I'm having trouble doing the same.
Quotetypedef struct _ofdpfolder {
    ucstr_t* name;
    unsigned long numFiles;
    unsigned long numFolders;
    ofdpfile_t* files;
    ofdpfolder_t* folders; // line 21
} ofdpfolder_t;
This is the code I'm trying to use, but gcc is telling me:
Quote from: GNU C Compilerfiles.h:21: error: parse error before "ofdpfolder_t"
Any ideas on how I can get this to work properly?

Arta

change that line to:


struct ofdpfolder_t* folders; // line 21

shadypalm88

Well, that didn't work, but I think I know what you meant.  Although I thought I had the line as
Quotestruct _ofdpfolder* folders; // line 21
before, and it didn't work, that's how it reads now, and it works fine.  Thanks.

Arta

hmm, yes, that'd be it. I never typedef my structs so I didn't notice :)