I was wondering how to split a project into multiple files. I had created a project divided into 3 files first, a main.c (containing main function), a lib.c (implementation of the functions used in main.c) and a lib.h (contains function prototypes), "uniting" the files using #include "lib.h" in main.c and lib.c - and worked perfectly.
But now I need to split the project (the same I finished using only 3 files) into more files, eg main.c, lib1.c, lib1.h, lib2.c, lib2.h ... being almost all functions remain the same. But now I can not 'make it work' and I get messages like:
"error: dereferencing pointer to incomplete type"
I would like to know how to "merge" these files when compiling.
More information about my project: Many of the functions use implementations that are in other "file.c". I'm using CodeBlock and DevC ++. An example of how the code is now:
main.c:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "lib1.h"
#include "lib2.h"
#include "lib3.h"
...
int main()
{
...
[uso das funções...]
...
}
lib1.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "lib1.h"
#include "lib2.h"
#include "lib3.h"
...
struct item1{
...
};
ITEM1* funcao1(ITEM2* lista, int valor)
{
...
}
ITEM1* funcao2(ITEM1* lista)
{
...
}
...
lib1.h
typedef struct item1 ITEM1;
ITEM1* funcao1(ITEM2* lista, int valor);
ITEM1* funcao1(ITEM1* lista);
...
lib2.h
typedef struct item2 ITEM2;
ITEM2* funcao5(...);
...
... (other .c and .h files)
How do I make it work?