0

I'm trying to implement a simple priority queue from array of queues. I'm trying to define a struct queue, and than a struct priority queue that has an array of queues as its member variable. However, when I try to compile the code, I get the following error:

pcb.h:30: error: array type has incomplete element type

The code is below:

typedef struct{
    pcb *head;
    pcb *tail;
    SINT32 size;
} pcb_Q;

typedef struct {
 struct pcb_Q queues[5];
 SINT32 size;
} pcb_pQ;

Could someone give me a hand? Thanks a lot.

1
  • You cite an error on line 30. But don't provide enough context to know the line numbers. Please make the line-numbering clear, and make sure you include line 30. Commented May 24, 2010 at 5:22

3 Answers 3

3

You already typedef the pcb_Q, no need to use struct keyword any more. Just use this:

typedef struct { 
    pcb_Q queues[5]; 
    SINT32 size; 
} pcb_pQ;
Sign up to request clarification or add additional context in comments.

Comments

1
typedef struct {
 pcb_Q queues[5];
 SINT32 size;
} pcb_pQ;

Your struct type has no name. Only the typedef is called pcb_Q.

Comments

1

I don't like this line:

struct pcb_Q queues[5];

Which references structure pcb_Q.

You have not defined pcb_Q as a structure. Instead, you typedef'd pcb_Q as a new type (which happens to be an un-named struct).

Try this instead:

pcb_Q queues[5];

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.