Passando argumento de Aviso de Tipo de Ponteiro Incompatível
Eu tenho tentado descobrir indicadores em C a maior parte de hoje, até pedi a umPergunta, questão mais cedo, mas agora estou preso em outra coisa. Eu tenho o seguinte código:
typedef struct listnode *Node;
typedef struct listnode {
void *data;
Node next;
Node previous;
} Listnode;
typedef struct listhead *LIST;
typedef struct listhead {
int size;
Node first;
Node last;
Node current;
} Listhead;
#define MAXLISTS 50
static Listhead headpool[MAXLISTS];
static Listhead *headpoolp = headpool;
#define MAXNODES 1000
static Listnode nodepool[MAXNODES];
static Listnode *nodepoolp = nodepool;
LIST *ListCreate()
{
if(headpool + MAXLISTS - headpoolp >= 1)
{
headpoolp->size = 0;
headpoolp->first = NULL;
headpoolp->last = NULL;
headpoolp->current = NULL;
headpoolp++;
return &headpoolp-1; /* reference to old pointer */
}else
return NULL;
}
int ListCount(LIST list)
{
return list->size;
}
Agora em um novo arquivo eu tenho:
#include <stdio.h>
#include "the above file"
main()
{
/* Make a new LIST */
LIST *newlist;
newlist = ListCreate();
int i = ListCount(newlist);
printf("%d\n", i);
}
Ao compilar, recebo o seguinte aviso (oprintf
A instrução imprime o que deveria):
file.c:9: warning: passing argument 1 of ‘ListCount’ from incompatible pointer type
Eu deveria estar preocupado com esse aviso? O código parece fazer o que eu quero, mas obviamente estou muito confuso sobre os ponteiros em C. Depois de navegar pelas perguntas neste site, descobri que se eu argumentar com ListCount(void *) newlist
, Não recebo o aviso e não entendo o porquê nem o que(void *)
realmente faz ...
Qualquer ajuda seria apreciada, obrigado.