On Sat, 07 Feb 2004 19:40:34 GMT, DrUg13 <> wrote
in comp.lang.c++:
> #ifndef HEADER_H
> #define HEADER_H
>
> blah blal
> #endif
>
> So this tells the compiler That if its defined do not define it again.
> Could someone help me understand this.
No, it means that if the preprocessor macro HEADER_H is already
defined, ignore the code up until the corresponding #endif. This
prevents the contents of a file from being processed more than once in
compiling the same source file even if it happens to be included more
than once.
> Does this mean that if I use the same clasee in two different classes
> in the same exe with out the above, that the exe would be larger
> because the code would be linked twice, or basically put into the code
> twice??
This usage, commonly called an "include guard", prevents the contents
in between the #ifndef and the #endif from being processed more than
once in any given source file. It will still be processed once only
for every individual source file in a program that includes it at
least once.
Note that proper usage for headers is that they should not define
actual variables or contain the bodies of any functions except for
inline member functions of classes. The definitions of type, such as
class definitions, and function prototypes do not in themselves
generate code or data.
--
Jack Klein
Home:
http://JK-Technology.Com
FAQs for
comp.lang.c
http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++
http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html