Reputation: 225
I'm trying to use a header to declare some Macros for the pre-processor and use them in the code file.
That's my header : error.h
#ifndef PROJET_MODULE_H
#define PROJET_MODULE_H
#define TESTMACRO 5
#endif
and the code file : error.c
#include <error.h>
#include <stdio.h>
int main(){
printf("%d\n", TESTMACRO);
return 0;
}
And I get this error :
‘TESTMACRO’ undeclared (first use in this function)
I've tried to compile doing :
gcc error.c -o error
and
gcc error.h error.c -o error
Both gave me the error.. Any help appreciated, thanks
Upvotes: 0
Views: 634
Reputation: 280
To include System header file you can use <>
or ""
To include Custom header file you should use "error.h"
or "absolute path of error.h"
If you still want to include you custom header file using <>
you should compile using following command.
gcc error.c -I <path of folder in which error.h resides> -o error
e.g if error.h is in /user/testuser/include/error.h then
gcc error.c -I /user/testuser/include/ -o error
Upvotes: 1
Reputation: 1251
To sum up everything said in comment :
To include non-system headers, you have to use "
and not <>
The resquest was solved changing #include <error.h>
to #include "error.h"
Upvotes: 1