Alex Rivera | Logout

How to not #include <windows.h>

Asked 2010-06-14T11:22:15.163
10

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

Edit
Report

1 Answer

2

Research the APIs and make sure the headers are included in the correct order. It's not hard to not use Windows.h; but you'll learn about the MS headers in the process.

There are a few headers you have to be aware of:

WTypes.h
WinDef.h
WinBase.h
WinObject.h
answered 2012-03-05T15:32:33.907

Your Answer