views:

177

answers:

3

Using MSVC2008, 32bit on 64bit system.

I was once advised to never include windows.h as 'its a real monster and will slow down my compile times significantly'.

I tried leaving it out and obviously get compile errors. I included windef.h to define all the DWORDs etc, but I quickly come unstuck knowing what else to define to get the code to compile.

I now get:

2>c:\program files\microsoft sdks\windows\v7.0\include\winnt.h(6361) : error C2146: syntax error : missing ';' before identifier 'ContextRecord'
2>c:\program files\microsoft sdks\windows\v7.0\include\winnt.h(12983) : error C2065: 'PCONTEXT' : undeclared identifier

Can anyone suggest the right approach here?

Thanks

Simon

+7  A: 

Internally, windows.h respects many defines, like NOMINMAX or LEAN_AND_MEAN.

It reduces the times significantly.

Pavel Radzivilovsky
WIN32_LEAN_AND_MEAN – used to reduce the size of the header files and speed up compilation. Excludes things like cryptography, DDE, RPC, the Windows Shell and Winsock.
Sjoerd
+17  A: 

Use precompiled headers to improve compile times, and include windows.h.

Sjoerd
+1 The problem is not the inclusion of windows.h but rather build speed. Parallel builds should help also (IncrediBuild for example)
Iulian Şerbănoiu
+5  A: 

The correct answer would be "include it in the PCH". Pre-compiled headers reduce compilation time dramatically, and, contrary to popular belief, this is true also for Full Rebuilds.

If you have more than one CPP file in your project, the "Rebuild all" would build it once for the whole project, which merely ads a few seconds to compile time - to have windows.h included in all of them.

Pavel Radzivilovsky