首页 > C- assignment from incompatible pointer type?

C- assignment from incompatible pointer type?

网上搜了好多报这种warning的,但都没有我的这些奇怪,求大神指教。

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

typedef struct _node {
    int Coefficient;
    int Exponent;
    struct Node *next;
} Node;

typedef struct _list {
    Node * head;
} List;
void insert(List * pList, int coeff, int expon);
void print(const List *pList);
int main()
{
    List list1, list2, listSum, listProd;
    list1.head = NULL;
    list2.head = NULL;
    listSum.head = NULL;
    listProd.head = NULL;
    int n, m;
    int i;
    int coeff, expon;
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%d %d", &coeff, &expon);
        insert(&list1, coeff, expon);
    }
    scanf("%d", &m);
    for (i = 0; i < m; i++) {
        scanf("%d %d", &coeff, &expon);
        insert(&list2, coeff, expon);
    }
    print(&list1);
    print(&list2);
    return 0;
}

void insert(List * pList, int coeff, int expon)
{
    Node *p = (Node *)malloc(sizeof(Node));
    p->Coefficient = coeff;
    p->Exponent = expon;
    p->next = NULL;
    Node *last = pList->head;
    if (last) {
        while (last->next) {
            last = last->next;  //[Warning] assignment from incompatible pointer type
        }
        last->next = p;   //[Warning] assignment from incompatible pointer type
    }
    else {
        pList->head = p;
    }
}

void print(const List *pList)
{
    Node *p;
    for (p = pList->head; p; p = p->next) {     //[Warning] assignment from incompatible pointer type
        printf("%d %d", p->Coefficient, p->Exponent);
        if (p->next) {
            printf(" ");
        }
    }
    printf("\n");
}

dev gcc4.9.2 报warning,但是为什么报warning呢?
求大神指教:)


gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04)
变异只报warning:
test.c: In function ‘insert’:
test.c:49:18: warning: assignment from incompatible pointer type [enabled by default]

         last = last->next;  //[Warning] assignment from incompatible pointer type
              ^

test.c:51:20: warning: assignment from incompatible pointer type [enabled by default]

     last->next = p;   //[Warning] assignment from incompatible pointer type
                ^

test.c: In function ‘print’:
test.c:61:32: warning: assignment from incompatible pointer type [enabled by default]

 for (p = pList->head; p; p = p->next) {     //[Warning] assignment from incompatible pointer type
      

执行也没有出现错误

【热门文章】
【热门文章】