hey, C hackers

Post Reply
Malcolm
Posts: 32040
Joined: Fri May 21, 2004 1:04 pm
Location: Minneapolis

Post by Malcolm »

I have this situation. Consider two structs that look like this ...

struct A { struct B s1; };
struct B { struct A s2; };


Compiler tosses an incomplete type error cos it obviously can't allocate memory for struct A till it knows struct B. But struct B needs struct A first.

What's the syntax that assures the compiler that struct B gets defined later, so I can initially define struct A?
Diogenes of Sinope: "It is not that I am mad, it is only that my head is different from yours."
Arnold Judas Rimmer, BSC, SSC: "Better dead than smeg."
TheCatt
Site Admin
Posts: 57673
Joined: Thu May 20, 2004 11:15 pm
Location: Cary, NC

Post by TheCatt »

HAHAHAHA! C!

Good one.
It's not me, it's someone else.
Malcolm
Posts: 32040
Joined: Fri May 21, 2004 1:04 pm
Location: Minneapolis

Post by Malcolm »

TheCatt wrote:HAHAHAHA! C!

Good one.
Yeah, this assignment appears to be : 1% thinking, 99% figure out how to do forward declaration in C w\ a union that uses five structs, each of which also uses the union. Both my classes have quickly devolved to suckage this semester.
Diogenes of Sinope: "It is not that I am mad, it is only that my head is different from yours."
Arnold Judas Rimmer, BSC, SSC: "Better dead than smeg."
TheCatt
Site Admin
Posts: 57673
Joined: Thu May 20, 2004 11:15 pm
Location: Cary, NC

Post by TheCatt »

Just reinforces my notion that school is pretty much worthless.
It's not me, it's someone else.
GORDON
Site Admin
Posts: 56735
Joined: Sun Jun 06, 2004 10:43 pm
Location: DTManistan
Contact:

Post by GORDON »

Don't you mean ChEckers?
"Be bold, and mighty forces will come to your aid."
Malcolm
Posts: 32040
Joined: Fri May 21, 2004 1:04 pm
Location: Minneapolis

Post by Malcolm »

I did some digging & found a way to do it w\ about 10 header files in preprocessor statements. So, in preliminary testing, it works.
Diogenes of Sinope: "It is not that I am mad, it is only that my head is different from yours."
Arnold Judas Rimmer, BSC, SSC: "Better dead than smeg."
Malcolm
Posts: 32040
Joined: Fri May 21, 2004 1:04 pm
Location: Minneapolis

Post by Malcolm »

TheCatt wrote:Just reinforces my notion that school is pretty much worthless.
Not to be all doom & gloom on that system (since I'm kinda in it), but you're right more than 50% of the time.
Diogenes of Sinope: "It is not that I am mad, it is only that my head is different from yours."
Arnold Judas Rimmer, BSC, SSC: "Better dead than smeg."
Post Reply