Hi, where should you place #include's inside of a header file for "best practice" ?
Ex:
Or does it not matter at all?Code:// Header.h // #include here or below? #ifndef HEADER_H_ #define HEADER_H_ // #include here or above? // ... #endif HEADER_H_
This is a discussion on Including headers in a header file within the C++ Programming forums, part of the General Programming Boards category; Hi, where should you place #include's inside of a header file for "best practice" ? Ex: Code: // Header.h // ...
Hi, where should you place #include's inside of a header file for "best practice" ?
Ex:
Or does it not matter at all?Code:// Header.h // #include here or below? #ifndef HEADER_H_ #define HEADER_H_ // #include here or above? // ... #endif HEADER_H_
"When your work speaks for itself - don't interrupt!"
-Samantha Ingraham.
If the headers you're including are also header-guarded it shouldn't matter, but they should be inder the header guards. So between the #define and #endif. If you think about it that part of the code will only be compiled once, and that's all you need/want.
Ah makes sense. Thanks! ^^
"When your work speaks for itself - don't interrupt!"
-Samantha Ingraham.
Also, if you do it the other way round, the include guard optimization that most compilers have doesn't kick in.
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law