我收到一条错误,说明'以下代码的'Graph'的类型有冲突,但我不确定是什么问题,因为在任何地方使用Graph之前都会声明它。谁知道问题是什么?
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#define __USE_BSD // make prototype for strdup visible
#include <string.h>
typedef struct linkedlist { // linked list of ints (for use in Node)
int index;
struct linkedlist *next;
} List;
typedef struct { // a Node of a Graph
char *name;
List *outlist; // adjacency list
int outdegree; // length of outlist
int indegree; // length of inlist
int dfsnum;
//double pagerank_score; //not needed for this exercise
} Node;
typedef struct {
int MaxSize;
Node *table;
} Graph;
// use to check result of strdup, malloc etc.
extern void check (void *memory, char *message);
extern int initialize_graph (Graph *mygraph, int MaxSize);
extern int insert_graph_node (Graph *mygraph, int n, char *name);
extern int insert_graph_link (Graph *mygraph, int source, int target);
extern int read_graph (Graph *mygraph, char *filename);
extern void print_graph (Graph *mygraph);
答案 0 :(得分:0)
我不确定,但我认为CDT MinGW有一个扩展的C lib,它已经保留了一个名为&#34; Graph&#34;的变量名,你试过重命名你的结构吗?虽然我之前从未使用过CDT MinGW,但可能就是这种情况。