Quote:
Originally posted by KissDaFeetOfSean
Hi,
I know this is probably a stupid question, but can someone please explain in plain English what the purpose of "#ifndef" is? I.e., say we have a C header file like this, named "header.h":
#ifndef MY_HEADER_FILE
#define MY_HEADER_FILE
/* some function declarations */
#endif
Is this merely to avoid duplication of including header files? And why the capital letters for the MY_HEADER_FILE? Thanks.
Sean
|
Yeah. This means if MY_HEADER_FILE is not defined then continue else ommit the part between
ifndef ......endif
In the case you have posted, it is to avoid including the same header files multiple times.
I'm don't think capital letters are needed, but this is a notation used for many years, so keep it this way. In the procompiler commands it's consider good style to use UPPERCASE