Like not #include <windows.h>

Using MSVC2008, 32 bit on a 64-bit system.

I was once advised to never include windows.h as "its a real monster and significantly reduce compilation time."

I tried to leave it and obviously get compilation errors. I have included windef.h to determine all DWORDs, etc., but I quickly get rid of it, knowing what else needs to be defined to compile the code.

Now I 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
c ++ include visual-studio-2008
source share
4 answers

Internally, windows.h respects many, such as NOMINMAX or WIN32_LEAN_AND_MEAN.

This significantly reduces the time.

+13
source share

Use precompiled headers to improve compilation time and enable windows.h.

+24
source share

The correct answer would be โ€œinclude it in PCHโ€. Precompiled headers significantly reduce compilation time, and contrary to popular belief, this is true for Full Rebuilds as well.

If your project has more than one CPP file, Rebuild all will build it once for the entire project, which simply advertises a few seconds to compile the time to include windows.h in all of them.

+8
source share

Examine the API and make sure that the headers are included in the correct order. Itโ€™s easy not to use Windows.h; but you will learn about MS headers in this process.

There are several headings you should be aware of:

 WTypes.h WinDef.h WinBase.h WinObject.h 
+2
source share

All Articles