I'm sorry about the 'shame on you'. It's just that i have know a lot of "programmers" (<- Notice the quotes) who just said: "I don't know what this does, so i remove it!". So it was not directect at your person, please don't be offended by it!
The short explanation from the above:
This sequence:
#ifndef TheUniqueVariableGuardingTheMultipleInclusionOfThisHeaderFile_h_
#define TheUniqueVariableGuardingTheMultipleInclusionOfThisHeaderFile_h_
...
#endif // TheUniqueVariableGuardingTheMultipleInclusionOfThisHeaderFile_h_
is used to guard a header file from being included multiple times in a C/C++ file before compiling.
As you probably know a typedef can only be defined once while compiling a C/C++ file. When a header file (which contains a typedef) is included twice in a C/C++ file the compiler will generate an error that the typedef was defined before.
Using the guarding statements, this will not happen!
It's the reason for using them! You should use them because it will make coding a big project allot easier!
To explain what it does exactly i will use the example from my previous post. Before the compiler compiles socketToSerial.cpp, the preprocessor is run. This will generate a new socketToSerial.cpp with all preprocessor commands processed.
The new file will look like this:
---socketToSerial.cpp---
typedef unsigned char uint8 // from the #include "serialPort.h"
typedef unsigned char uint8 // from the #include "sockets.h"
---------------------------
And when the compiler tries to compile this file, it will generate an error!
When the guarding statements where used here, the folowing file would have been generated:
---socketToSerial.cpp---
typedef unsigned char uint8 // from the #include "serialPort.h"
// from the #include "sockets.h" (the guarding variable for types.h was already defined so nothing here!
---------------------------
Antharax