0

In our class we are to implement a kernel built on a bochs simulator.

One of the subtasks is to implement fixed priority scheduling. Previously our scheduler was only one thread queue, but now i wanted to make an array of thread queues.

But my array keeps getting a comiler error "array type has incomplete element type" i posted some of the code below, can anyone see the problem.

kernel.h

...
extern struct thread_queue
ready_queue_table[MAX_SYS_PRIORITY];
...

kernel.c

...
#include <sysdefines.h>
#include "threadqueue.h"
...
struct thread_queue
ready_queue_table[MAX_SYS_PRIORITY];
...

sysdefines.h

...
#define MAX_SYS_PRIORITY         (5)
...

threadqueue.h

...
struct thread_queue
{
 int head;  /*!< The index to the head of the thread queue.
                 Is -1 if queue is empty. */
 int tail;  /*!< The index to the tail of the thread queue.
                 Is -1 if queue is empty. */
};
...
1
  • Which line causes the error message? Commented Apr 30, 2012 at 15:48

2 Answers 2

2

You need to have the definition of the structure whos array you create before creating the array(the compiler needs to see the definition of type whos array you create), othewise the type is an Incomplete type for the compiler and it does not know the memory layout of that type and hence cannot create an array of it.

You should put the definition of the structure in a header file and include it whichever files you want to refer to structure elements or do some action which needs the compiler to know of the structure layout.

Sign up to request clarification or add additional context in comments.

2 Comments

+1 ~addendum @Tommy Sadiq Hinrichsen: going from your code snippet, if you move #include kernel.h below your #include "threadqueue.h" then it should compile
I can see the problem now, thx for your help. Unfortunatly its not easy moving the #include statements since there are many dependancies.
0

In kernel.h you have this:

extern struct thread_queue
ready_queue_table[MAX_SYS_PRIORITY];

I suspect that there are instances of thing including kernel.h where threadqueue.h isn't already included. I think you'll either need to add #include "threadqueue.h" to kernel.h or remove that extern.

But all this is just a guess since the code snippets are pretty sparse.

1 Comment

Neither helped, i could paste the entire code, but its fairly long.

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.