Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
GCC help
#1
Is there a way to have a struct hold an pointer to an instance of itself?


Code:
typedef struct{
     int size;
     int blocksize;
     cache *subcache;
} cache;

I know that this code doesn't work, is there a trick to doing it somehow?
f you play a Microsoft CD backwards you can hear demonic voices. The scary part is that if you play it forwards it installs Windows.
Reply
#2
Code:
typedef struct _cache{
     int size;
     int blocksize;
     cache *subcache;
} cache;

Try that. If it doesn't work, it's because I've been coding deprived for a while.
.14159265358979323846264338327950288419716939937510582709445
Glarplesnarkleflibbertygibbertygarbethparkentalelelangathaffendoinkadonkeydingdonkaspamahedron.
Reply
#3
Looks like you're code deprived, it doesn't work :b

It's ok, I used to be good at C too, anyone else got an idea?
f you play a Microsoft CD backwards you can hear demonic voices. The scary part is that if you play it forwards it installs Windows.
Reply
#4
Have you tried just doing this:

Code:
typedef struct cache{
     int size;
     int blocksize;
     cache *subcache;
} cache;

?

It works for me anyway.
url=http://www.copy-pasta.com]CopyPasta[/url] - FilePasta
Reply
#5
Yeah, I tried that, I got a parse error, same as the one with the underscore.
f you play a Microsoft CD backwards you can hear demonic voices. The scary part is that if you play it forwards it installs Windows.
Reply
#6
Code:
typedef struct cache_st
{
    int size;
    int blocksize;
    struct cache_st* subcache;
} cache_t;
img]http://www.cdsoft.co.uk/misc/shiftlynx.png[/img]
Reply
#7
That's it.

Thanks.
f you play a Microsoft CD backwards you can hear demonic voices. The scary part is that if you play it forwards it installs Windows.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)