Dereferencing pointer to incomplete type
Just trying to figure out why I would need to define struct point a second time in main.c in order to remove the dereferencing pointer to incomplete type error I am having in main.c?
Am I tackling this all wrong?
point.h
Code:
typedef struct point* point_t;
point_t create_point();
point.c
Code:
#include <point.h>
struct point{
int x;
int y;
};
point_t create_point(){
point_t p = malloc(sizeof(point_t));
p->x = 10;
printf("%d\n", p->x); // fine prints 10
return p;
}
main.c
Code:
#include "point.h"
int main(void){
point_t my_point = create_point();
// Dereferencing pointer to incomplete type
printf("%d\n", my_point->x);
return 0;
}