i had problem to split program on more files .c and .h on main.ci put a struct like
struct listnumbers {
float number;
struct listnumbers *next;
};typedef struct listnumbers *list;
the problem come when i need to compile all files .c .h and compilator give me an error like Unknown type name "list" on sorting.h = void sorting(list *pt,float number)
C is case sensitive. Struct
should be struct
.
The way to go with structs in C is
#include
it only in files needing the struct
. In other words, write a proper interface and place the interface declaration in the header, the interface implementation in a C file. You need to define your structs in .h files that you include where the struct is used.
Unknown type name "list" on sorting.h tries to tell you that while processing sorting.h
the list
is unknown.
You can also shorten ist definition by combining typedef + struct.
typedef struct listnumbers {
float number;
struct listnumbers *next;
} *list;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.