struct

Started by
3 comments, last by Tiger99 21 years, 1 month ago
Hello Does anyone know what''s the problem of the following declarting of struct? I am getting a redefiniation of struct pcb error Thanks #define PCB struct pcb PCB { PCB *ptr; char *name; UINT32 id; UINT32 flag; UINT32 program_counter; // DATA REGISTER UINT32 reg_D0; UINT32 reg_D1; UINT32 reg_D2; UINT32 reg_D3; UINT32 reg_D4; UINT32 reg_D5; UINT32 reg_D6; UINT32 reg_D7; // ADDRESS REGISTER UINT32 reg_A0; UINT32 reg_A1; UINT32 reg_A2; UINT32 reg_A3; UINT32 reg_A4; UINT32 reg_A5; UINT32 reg_A6; UINT32 reg_A7; UINT32 process_state; UINT32 priority; MSG_ENV *msg_ptr_head; MSG_ENV *msg_ptr_tail; };
Advertisement

#define PCB struct pcb

PCB
{
PCB *ptr;


this expands to


struct pcb
{
struct pcb *ptr;


your redefining the struct inside the struct


extended waranty, how can I lose!

[edited by - brass_fish on March 15, 2003 10:50:12 PM]

[edited by - brass_fish on March 15, 2003 10:51:21 PM]
extended waranty, how can I lose!
I could be wrong about this (it''s been a while since I looked at the C standard) but I don''t think compilers are required to allow pointers to incomplete types. Try sticking "struct pcb;" before your definition, and see if that fixes it.

But... but that''s what HITLER would say!!
C compilers are required to support pointers to incomplete types (Section 6.2.5 paragraph 19 in the C99 standard (well the final draft anyway)). btw, inserting struct pcb; before it''s definition doesn''t change the fact that is an incomplete type inside the definition.

As far as I can tell, unless your definitions of UINT32 and MSG_ENV are really screwy, your declaration is fine by itself. Emphasis on by itself . If you have in a header file and forgot inclusion guards it could cause problems.
You guys don''t know shit!!!
so BS...

and your extended warranty sucks...

This topic is closed to new replies.

Advertisement