445,918 Members | 2,246 Online Need help? Post your question and get tips & solutions from a community of 445,918 IT Pros & Developers. It's quick & easy.

# derefrencing pointer to incomplete type

 P: n/a 1) #include #include #include "graph.h" #define MAX_VTX 4 struct _graph_vertex { char *label; int exectime; }; struct _graph_edge { int produced, consumed, delay; }; struct _graph { graph_vertex vertices[MAX_VTX]; graph_edge_pointer adjmtx[MAX_VTX][MAX_VTX]; }; graph_pointer graph_construct(int *src, int *snk, int cnt) { graph_type g; graph_pointer gpt; graph_vertex_pointer gvt; int i,j; for(i=0 ; i < MAX_VTX ; i++) { for(j=0 ; j < MAX_VTX; j++) g.adjmtx[i][j]=NULL; } //for(i=0;iproduced); printf("Enter Consumed for Edge %d\n",i); scanf("%d", &g.adjmtx[src[i]][snk[j]]->produced); printf("Enter Delay for Edge %d\n",i); scanf("%d", &g.adjmtx[src[i]][snk[j]]->produced); } gpt = &g; printf("%d",gpt->vertices.exectime); return gpt; } 2) #include #include #include "graph.h" int main() { int src_vtx[]= {0,1,3,0,3}; int snk_vtx[] = {1,2,2,3,1}; int edgcnt = sizeof(src_vtx)/sizeof(int); graph_pointer gp; gp = graph_construct(src_vtx,snk_vtx,edgcnt); printf("%d",gp->vertices.exectime); I am getting error over here: gcc : derefrencing pointer to incomplete type vc++ : left of 'vertices' specifies undefined struct/union '_graph' return 0; 3) graph.h #ifndef _graph_h #define _graph_h #include "floatmath.h" /* A vertex in a graph. */ typedef struct _graph_vertex graph_vertex; /* A pointer to a graph vertex. */ typedef graph_vertex *graph_vertex_pointer; /* An edge in a graph. */ typedef struct _graph_edge graph_edge; /* A pointer to a graph edge. */ typedef graph_edge *graph_edge_pointer; /* A graph. */ typedef struct _graph graph_type; /* A pointer to a graph. */ typedef graph_type *graph_pointer; /* An array of pointers to graph edges. */ typedef graph_edge_pointer *graph_edge_array; graph_pointer graph_construct(int *, int *, int); #endif Sep 30 '06 #1
5 Replies 