-1

对于以下代码,我收到一条错误消息,提示“'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);
4

1 回答 1

0

我不确定,但我认为 CDT MinGW 有一个扩展的 C 库,它已经保留了一个名为“Graph”的变量名,你试过重命名你的结构吗?虽然我以前从未与 CDT MinGW 合作过,但可能就是这种情况

于 2013-04-27T12:55:44.443 回答