'尽管在头文件和文件中声明,'ISO C90禁止混合声明和代码' c99 flag

时间:2016-12-13 03:50:02

标签: compiler-warnings

我查看了相关帖子,并了解了这个错误的含义。 我也是相对较新的发布在这里,所以,任何有问题的格式让我知道。

我不明白的原因仍然是我的代码中发生的原因。请注意,这些代码中的一些是导入的。然而,这很简单,我已经阅读并将其调整为我的设计。

我还尝试将C99标志添加到我的makefile中,但它仍然返回错误。也许我加错了?

感谢您的帮助!

主文件中的这一行发出警告:

graph_p undir_graph = createGraph(example, UNDIRECTED);

这是我的头文件:

#define PESO 765
#define MAXLENGTH 50



typedef struct _No {
  char *palavra;
  struct _No *prox;
} No;


typedef struct _Info {
  int m;                        /* dimension of the vector */
  int numPalavras;              /* number of different words  */
  int *num_pal;                 /* hash table hits count */
  int num_comp;                 /* number of comparisons */
  int max_size;         /* size of the biggest list */
  int empty;            /* number of empty lists */
} Info;


typedef No *Hash;               /* typedef for hash table */

typedef enum {UNDIRECTED=0,DIRECTED} graph_type_e;

/* Adjacency list node*/
typedef struct adjlist_node
{
    int vertex;                /*Index to adjacency list array*/
    int weight;                /*Weight of edge to index*/
    struct adjlist_node *next; /*Pointer to the next node*/
}adjlist_node_t, *adjlist_node_p;



/* Adjacency list */
typedef struct adjlist
{
    int num_members;           /*number of members in the list (for future use)*/
    adjlist_node_t *head;      /*head of the adjacency linked list*/
}adjlist_t, *adjlist_p;

/* Graph structure. A graph is an array of adjacency lists.
   Size of array will be number of vertices in graph*/
typedef struct graph
{
    graph_type_e type;        /*Directed or undirected graph */
    int num_vertices;         /*Number of vertices*/
    adjlist_p adjListArr;     /*Adjacency lists' array*/
}graph_t, *graph_p;



void displayGraph(graph_p);
void fillEdges (graph_t *, Hash *, int);
void addEdge(graph_t *, int, int, int);
void destroyGraph(graph_p);
graph_p createGraph(int, graph_type_e);
adjlist_node_p createNode(int, int);
void ResolveProblema(Hash *, char *);
int CheckWord(Hash *, char *, int);
char *LePalavra(FILE *);
FILE *AbreFicheiro(char *, char *);
No *AlocaNo(char *);
void AcrescentaNo(No *, No *);
Hash *AlocaTabela(int);
int Disperse(char *);
void InsereNaTabela(Hash *, Info *, char *);
void PreencheTabelaPalavras(Hash *, Info *, char *);
void EscreveFicheiro(Hash *, char *, int);
void MostraDistribuicao(Hash *, Info *);
void LibertarTabela(int, Hash *);
void LibertarNo(No *);

这是我的主要计划:

#include <stdlib.h>
#include <string.h>
#include <stdio.h>

#include "pal.h"

int main(int argc, char **argv)
{
  Hash *tabela;                 /* pointer for a vector of No */
  Info h;
  int example;

  if (argc < 3) {
    printf("usage: %s infile m\n", argv[0]);
    return -1;
  }
  h.num_comp = 0;
  h.numPalavras = 0;
  h.m = MAXLENGTH;
  h.num_pal = (int *)calloc(h.m, sizeof(int));
  tabela = AlocaTabela(h.m);
  PreencheTabelaPalavras(tabela, &h, argv[1]);
  example = h.num_pal[10];

    graph_p undir_graph = createGraph(example, UNDIRECTED);

    fillEdges (undir_graph, tabela, 4);
    /*displayGraph (undir_graph);*/

 EscreveFicheiro(tabela, argv[1], h.m);

  /* shows graphically the distribution of the words in the hash table */

  MostraDistribuicao(tabela, &h);
  printf("\nNumber of diferent words: %d\n", h.numPalavras);
  printf("Size of the biggest list: %d\n", h.max_size);
  printf("Number of empty lists: %d\n", h.empty);

  LibertarTabela(h.m, tabela);
  free(tabela);
  free(h.num_pal);

  return 0;
}

这是我的makefile:

CC=gcc
CFLAGS=-g -c -Wall -std=c99 -ansi -pedantic

hashpal: hash.o pal.o
    $(CC) -g -o hashpal hash.o pal.o


hash.o: hash.c pal.h
    $(CC) $(CFLAGS) hash.c

pal.o: pal.c pal.h
    $(CC) $(CFLAGS) pal.c


etags::
    etags *.h *.c

clean::
    rm -f *.o core a.out hashpal *~

0 个答案:

没有答案