I know it to prevent multiple inclusion of header file. But suppose I ensure that I will include this file in only one .cpp file only once. Are there still scenarios in which I would require this safe-guard?
So, meaning means "the effect that something has on one's preferences," and purpose means "the use that something has on our attaining one's preferences." They're closely linked.
Both are correct. “For the purpose of” is followed by a gerund, and the phrase can typically be replaced with “to” followed by an infinitive. “This spoon can be used for the purpose of stirring ingredients.”
Examples of purpose in a SentenceThe loans are small but they serve a good purpose. Sometimes his life seemed to lack purpose or meaning.
"for the purpose of" Example SentencesThis meeting has been called for the purpose of clarifying several important issues. For the purpose of improving security, the airport increased the number of guards. For the purpose of this discussion, gross revenue is a more important consideration than profits.
No, that's the only purpose of the include guards, but using them should be a no-brainer: doing it requires little time and potentially saves a lot.
You can guarantee that your code only includes it once, but can you guarantee that anyone's code will include it once?
Furthermore, imagine this:
// a.h
typedef struct { int x; int y; } type1;
// b.h
#include "a.h"
typedef struct { type1 old; int z; } type2;
// main.c
#include "a.h"
#include "b.h"
Oh, no! Our main.c
only included each once, but b.h
includes a.h
, so we got a.h
twice, despite our best efforts.
Now imagine this hidden behind three or more layers of #include
s and it's a minor internal-use-only header that gets included twice and it's a problem because one of the headers #undef
ed a macro that it defined but the second header #define
d it again and broke some code and it takes a couple hours to figure out why there are conflicting definitions of things.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With