If a particular header is already included in stdafx.h - do I need to (have to/should to) to explicitly include it in a .cpp file (which already includes the stdafx.h) ?
Asked
Active
Viewed 346 times
1 Answers
4
When stdafx is created for you it is typically a precompiled header. As a precomiled header it will be necessary to add it to any .cpp that is marked to use precompiled headers (normaly any cpp added to the project except for stdafx.cpp)
You don't need to include headers already included in stdafx.h, including it again may cause extra effort for the compiler.

Greg Domjan
- 13,943
- 6
- 43
- 59
-
1Even when using precompiled headers, you still have to use header guards or `#pragma once`. Including the same header twice is therefore trivially cheap; you can easily do so if it aids readability. – MSalters Nov 23 '10 at 09:22