I'm doing a project in C, and I have 3 files:
1 .c containing the definitions of functions and structs.
1 .h containing the prototypes of these functions and structs
ae1 .c that contains main.
In the .c with the definitions, I defined the struct:
typedef struct vector {
int numDePosicoes;
double vetor[5000];
}ESTRUCT;
And in the main method, I try to create an instance of this struct as follows:
int main(int argc,char* argv[]) {
ESTRUCT vetor;
//criando separadamente um ponteiro para a struct
ESTRUCT *ponteiroPraVetor = &vetor;
But gcc accuses the error: "error: unknown type name 'ESTRUCT'"
In both the creation of the struct, and in the creation of the pointer for it.
Note: I am using a Makefile to mount the program, follow it below:
CFLAGS=-Wall
Roteiro5exe: mainr5.o Roteiro5.o
mainr5.o: mainr5.c Roteiro5.h
Roteiro5.o: Roteiro5.c Roteiro5.h
clean:
rm *.o
NOTE: When I put all the code in the same file, and simply compile it, it works. Maybe the problem is in the makefile. Can anyone see it?