3 ms·
Also do not forget the more common case: - foo.c includes bar.h and baz.h - bar.h and baz.h both include qux.h This is why most C header files have ifdef gua
by pavanky 13y ago
Also do not forget the more common case:
- foo.c includes bar.h and baz.h
- bar.h and baz.h both include qux.h
This is why most C header files have ifdef guards like this
#ifndef __BAR_H
#define __BAR_H
// contents go here
#endif
This makes sure that the contents of the header are only included the first time the preprocessor sees it in a particular file
- ygra 13y agoHence include guards, yes. Agreed, I could have made that point a little better. Although they are usually only necessary when the header files contains things that may not appear twice in the same compilation unit, such as ... uhm, pretty much everything.