This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How avoid multiple includes of one file

Hi
I've split my project in 2 parts while each part is implemented by one.
So some includes like <reg51.h> is done twice which resulted in error. So in order to avoid this I did as follows:

#if !defined(REG51_h__INCLUDED_)
#define REG51_h__INCLUDED_
#endif

but it seems that this doesn't result in:
#include <reg51.h>
if it has not been included before.
How should I solve it?!!
I appreciate your attention in advance!!

Parents
  • put a define for the __FILENAME_H at the top of the file

    A note of caution here: unless you're a compiler or runtime system implementor (i.e. in the context of this NG: unless you work at Keil) you're forbidden to use that kind of name. All macro and external names with two leading underscores are reserved for use by compiler makers. This may seem like an overly
    nitpicky detail, but it can bite you, and if it does, it'll be one heck of a debugging session to find it.

    So, for your own benefit, change to a pattern like PROJECT_FILENAME_H.

Reply
  • put a define for the __FILENAME_H at the top of the file

    A note of caution here: unless you're a compiler or runtime system implementor (i.e. in the context of this NG: unless you work at Keil) you're forbidden to use that kind of name. All macro and external names with two leading underscores are reserved for use by compiler makers. This may seem like an overly
    nitpicky detail, but it can bite you, and if it does, it'll be one heck of a debugging session to find it.

    So, for your own benefit, change to a pattern like PROJECT_FILENAME_H.

Children