이전에 게시 한 동일한 문제의 답변을 찾으려고했지만 제대로 작동하지 않습니다. 내가 확인 한 링크 아래는 몇 :C 프로그래밍 : 매개 변수에 불완전한 형식 오류가 있습니다.
"parameter has incomplete type" warning C typedef: parameter has incomplete type How to resolve "parameter has incomplete type" error?
코드 :
: 여기#include "listADT.h"
#include "client.h"
#include <stdlib.h>
#include <stdio.h>
struct node {
ClientInfo *data; // added pointer here
struct node * next;
};
struct list_type {
struct node * front;
int size;
};
ListType create() {
ListType listptr = malloc(sizeof(struct list_type));
if (listptr != NULL) {
listptr->front = NULL;
listptr->size = 0;
}
return listptr;
}
void push(ListType listptr, ClientInfo item) { <--- error here
struct node *temp = malloc(sizeof(struct node));
if (temp != NULL) {
temp->data = item;
temp->next = listptr->front;
listptr->front = temp;
(listptr->size)++;
}
}
int is_empty(ListType l) {
return l->size == 0;
}
int size_is(ListType l) {
return l->size;
}
void make_empty(ListType listptr) {
struct node* current = listptr->front;
while (current->next != NULL) {
destroy(listptr);
current = current->next;
}
(listptr->size)--;
}
void destroy(ListType listptr) {
struct node *temp = malloc(sizeof(struct node));
temp = listptr->front;
listptr->front = listptr->front->next;
free(temp);
(listptr->size)--;
}
void delete(ListType listptr, ClientInfo item) { <--- error here
struct node* current = listptr->front;
struct node *temp = malloc(sizeof(struct node));
while (current-> data != item) {
temp = current;
current = current->next;
}
temp->next = current->next;
(listptr->size)--;
}
int is_full(ListType l) {
}
이 구조체로 클라이언트가 다른 C 파일에 포함 된 내용입니다
typedef struct ClientInfo {
char id[5];
char name[30];
char email[30];
char phoneNum[15];
} ClientInfo;
그리고 내가 받고있는 오류는 다음과 같습니다.
listADT.c:41:40: error: parameter 2 (‘item’) has incomplete type
void push(ListType listptr, ClientInfo item) {
^
listADT.c:83:42: error: parameter 2 (‘item’) has incomplete type
void delete(ListType listptr, ClientInfo item) {
나는 그것을 고치는 방법에 관해서 정말로 분실했다. 포함해야 할 다른 정보가 있으면 알려주십시오.
편집 부분 |
listADT.h : ClientInfo item
ClientInfo *item
로 변경 후
#ifndef LISTADT_H
#define LISTADT_H
typedef struct list_type *ListType;
typedef struct ClientInfo ClientInfo;
ListType create(void);
void destroy(ListType listP);
void make_empty(ListType listP);
int is_empty(ListType listP);
int is_full(ListType listP);
void push(ListType listP, ClientInfo item);
void delete(ListType listP, ClientInfo item);
void printl(ListType listP);
#endif
에러 :
listADT.h:12:6: note: expected ‘ClientInfo * {aka struct ClientInfo *}’
but argument is of type ‘ClientInfo {aka struct ClientInfo}’
void push(ListType listP, ClientInfo *item);
@kaylum은 게시하기 몇 초 전에 방금 추가했습니다. :) – Jasmine
"다른 c 파일에 있습니다". 그게 효과가 없을거야. 직접 사용하거나 포함 된 헤더 파일에서 사용되는 모든 C 파일에서 정의해야합니다. – kaylum
또는 매개 변수가 'ClientInfo * item'로 변경 될 수 있습니다. –