I've been trying to find answers from previous posts of my same issue but it's not working out. Below is only a few of the links I've checked:
- "parameter has incomplete type" warning
- C typedef: parameter has incomplete type
- How to resolve "parameter has incomplete type" error?
Code:
#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) {
}
Here is what the struct ClientInfo contains in another c file:
typedef struct ClientInfo {
char id[5];
char name[30];
char email[30];
char phoneNum[15];
} ClientInfo;
And here is the error I'm getting:
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) {
I'm absolutely lost at this point on how to fix it. Please let me know if there is any other info I need to include.
EDIT PORTION |
listADT.h:
#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
Error after changing ClientInfo item
to ClientInfo *item
:
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);