I am trying to create a queue by allocating memory to a pointer to a queue, yet I get this error when I write the name of the struct in the size slot. I really don't know how to explain this, so code:
structs, defined in queue.c:
struct queue {
Node front;
Node back;
int num;
int (*e_func)(Elem,Elem);
};
typedef struct node* Node;
struct node {
Elem e;
Node next;
Node prev;
};
queue.h:
#ifndef QUEUE_H
#define QUEUE_H
#include <malloc.h>
#include <stdlib.h>
typedef struct queue* Queue;
typedef void* Elem;
Queue CreateQ(int (*equals)(Elem,Elem));
void Enqueue(Queue Q, Elem e);
Elem Dequeue();
Elem front(Queue Q);
Elem back(Queue Q);
int size(Queue Q);
int isIn(Queue Q, Elem e);
#endif
Usage of queue, in funcs.c:
Queue Q = (Queue)malloc(sizeof(struct queue));
The error is shown when mousing over the struct
in the sizeof()
argument. What the hell did I do wrong? I remember doing something similar in the past and it worked. I believe it might have something to do with the void pointer in node, but how do I solve this?