Jump to content

error: dereferencing pointer to incomplete type


Vnepomuceno
 Share

Recommended Posts

Boa noite, estou a fazer um programa em C que mexe com filas e com threads (programação concorrente) mas está-me a dar o erro: "error: dereferencing pointer to incomplete type". O código é:

/* queue_element_t */
typedef struct queue_element {
    struct _sthread *thread;
    struct queue_element *next;
} queue_element_t;

/* queue_t */
typedef struct _queue {
  queue_element_t *first;
  queue_element_t *last;
} queue_t;

void queue_print(queue_t *queue) {
queue_element_t *el = queue->first;
struct _sthread *thr;

if(el == NULL) {
	return;
}
for(thr = el->thread; el != NULL; el = el->next, thr = el->thread) {
	printf(" %d,%d", thr->tid, thr->quantum);
}
printf("\n");
}

struct _sthread* queue_find_tid(queue_t *queue, int tid) {
queue_element_t *el;
struct _sthread *thr;

for(el = queue->first, thr = el->thread; el != NULL; el = el->next, thr = el->thread) {
	if(thr->tid == tid)
		return el->thread;
}
return NULL;
}

Esse erro é apontado duas vezes para a linha

printf(" %d,%d", thr->tid, thr->quantum);

e uma para a linha

if(thr->tid == tid)

Alguém me pode ajudar a detectar o que está mal nestas linhas e o que precisa de ser mudado?  :wallbash:

Obrigado

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.