We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hello!
I want to include the same headerfile in more than one sourcefile and of course have to take care that each Headerfile is included just once.
I really have no clue, why this works for the Headers provided by Keil but not with my own ones:
#ifndef _MYHEADER_H_ #define _MYHEADER_H_
//Headerfile content . ..
#endif
Obviously the preprocessor includes the Headerfile more than once and so i get errors.
When i add a statement within my Header like:
#warning "included more than once"
the warning message appears twice. (so the header is really included twice).
Can anyone tell me the problem please?!
Kind regards
So in my context i generally would not need it.
It's a good idea to use it in all your header files. Just to be safe.
However, i have compiled a Library in Keil and for this Library a Header File exists, in which all Prototypes of the functions defined in the Library are listed.
Maybe you could post a bit of code so all of us can have a look. Make sure you use the ANSI C keyword extern in the header file to tell the compiler that it's a declaration of a variable or function and not a (obviously multiple) definition
-- Joost