Using MSVC2008, 32bit on 64bit system.
使用MSVC2008, 32位在64位系统。
I was once advised to never include windows.h as 'its a real monster and will slow down my compile times significantly'.
我曾被建议不要包括windows。h作为“它是一个真正的怪物,将大大降低我的编译时间”。
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.
我试图省略它,显然会得到编译错误。我包括windef。h来定义所有的DWORDs等等,但是我很快就知道要定义什么来编译代码。
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
西蒙
4 个解决方案
#1
13
Internally, windows.h respects many defines, like NOMINMAX or WIN32_LEAN_AND_MEAN.
在内部,窗户。h尊重许多定义,如nammax或WIN32_LEAN_AND_MEAN。
It reduces the times significantly.
它大大减少了时间。
#2
24
Use precompiled headers to improve compile times, and include windows.h.
使用预编译头来改进编译时间,并包括windows.h。
#3
8
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.
正确的答案应该是“包含在PCH中”。预编译头大大减少了编译时间,与流行的看法相反,对于完整的重新构建也是如此。
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.
如果在您的项目中有多个CPP文件,那么“重建所有”将为整个项目构建一次,这仅仅是几秒钟的时间来编译时间——有windows。h包含在其中。
#4
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.
研究这些api,并确保将标题包含在正确的顺序中。不使用窗户并不难。但是您将在此过程中了解MS头。
There are a few headers you have to be aware of:
有一些标题你必须注意:
WTypes.h
WinDef.h
WinBase.h
WinObject.h
#1
13
Internally, windows.h respects many defines, like NOMINMAX or WIN32_LEAN_AND_MEAN.
在内部,窗户。h尊重许多定义,如nammax或WIN32_LEAN_AND_MEAN。
It reduces the times significantly.
它大大减少了时间。
#2
24
Use precompiled headers to improve compile times, and include windows.h.
使用预编译头来改进编译时间,并包括windows.h。
#3
8
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.
正确的答案应该是“包含在PCH中”。预编译头大大减少了编译时间,与流行的看法相反,对于完整的重新构建也是如此。
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.
如果在您的项目中有多个CPP文件,那么“重建所有”将为整个项目构建一次,这仅仅是几秒钟的时间来编译时间——有windows。h包含在其中。
#4
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.
研究这些api,并确保将标题包含在正确的顺序中。不使用窗户并不难。但是您将在此过程中了解MS头。
There are a few headers you have to be aware of:
有一些标题你必须注意:
WTypes.h
WinDef.h
WinBase.h
WinObject.h