| C Tutorial | Multiple #includes-- #pragma once | |||
|
main() Multiple Files Prototypes Preprocessor #define #include foo.h vs foo.c #if Multiple #includes -- #pragma once Assert
|
Multiple #includes -- #pragma once
There's a problem sometimes where a .h file is #included into a file more than one time resulting in compile errors. This can be a serious problem. Because of this, you want to avoid #including .h files in other .h files if at all possible. On the other hand, #including .h files in .c files is fine. If you are lucky, your compiler will support the #pragma once feature which automatically prevents a single file from being #included more than once in any one file. This largely solves multiple #include problems.
// foo.h // The following line prevents problems in files which #include "foo.h" #pragma once
<rest of foo.h ...> Want To Know more with Video ??? Contact for more learning: webmaster@freehost7com |
|