Jump to content
Sign in to follow this  
Vnepomuceno

error: dereferencing pointer to incomplete type

Recommended Posts

Vnepomuceno

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

Share this post


Link to post
Share on other sites
Vnepomuceno

Sim, é este:

struct _sthread {
  sthread_ctx_t *saved_ctx;
  sthread_start_func_t start_routine_ptr;
  long wake_time;
  int join_tid;
  void* join_ret;
  void* args;
  int tid;
  int nice;
  int priority;
  int quantum;
  int rem_quantum;
};

Share this post


Link to post
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
Sign in to follow this  

×
×
  • 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.