0

我在我的项目中关闭了扩展,但必须为任何包含 directx 或 windows 头文件的 cpp 文件打开它们。

如果我关闭这些 cpp 文件的扩展,它将无法编译。有没有办法让它工作?

使用语言扩展可以很好地编译。

我正在使用 VS2012 express、c++、directx9 和 Win7 64。

示例错误

1>c:\program files (x86)\windows kits\8.0\include\um\winnt.h(10907): error C2467: illegal declaration of anonymous 'struct'

1>c:\program files (x86)\windows kits\8.0\include\um\winnt.h(10918): error C2467: illegal declaration of anonymous 'struct'

1>c:\program files (x86)\windows kits\8.0\include\um\winnt.h(10930): error C2467: illegal declaration of anonymous 'struct'

1>c:\program files (x86)\windows kits\8.0\include\um\winnt.h(10940): error C2467: illegal declaration of anonymous 'struct'

1>c:\program files (x86)\windows kits\8.0\include\um\winnt.h(10950): error C2467: illegal declaration of anonymous 'struct'

1>c:\program files (x86)\windows kits\8.0\include\um\winnt.h(14764): error C2467: illegal declaration of anonymous 'struct'

1>c:\program files (x86)\windows kits\8.0\include\um\winnt.h(15404): error C2467: illegal declaration of anonymous 'struct'

1>c:\program files (x86)\windows kits\8.0\include\um\winnt.h(17421): error C2133: '_ACTIVATION_CONTEXT_COMPATIBILITY_INFORMATION::Elements' : unknown size

1>c:\program files (x86)\windows kits\8.0\include\um\wingdi.h(2202): error C2467: illegal declaration of anonymous 'struct'

1>c:\program files (x86)\windows kits\8.0\include\um\wingdi.h(2208): error C2467: illegal declaration of anonymous 'struct'

1>c:\program files (x86)\windows kits\8.0\include\um\wingdi.h(2256): error C2467: illegal declaration of anonymous 'struct'

1>c:\program files (x86)\windows kits\8.0\include\um\wingdi.h(2262): error C2467: illegal declaration of anonymous 'struct'

1>c:\program files (x86)\windows kits\8.0\include\um\wingdi.h(2807): warning C4309: 'initializing' : truncation of constant value

1>c:\program files (x86)\windows kits\8.0\include\um\wingdi.h(2809): warning C4309: 'initializing' : truncation of constant value

1>c:\program files (x86)\windows kits\8.0\include\um\wingdi.h(3008): error C2467: illegal declaration of anonymous 'struct'

1>c:\program files (x86)\windows kits\8.0\include\um\wingdi.h(3048): error C2467: illegal declaration of anonymous 'struct'

1>c:\program files (x86)\windows kits\8.0\include\um\winuser.h(14055): error C2467: illegal declaration of anonymous 'struct'

1>c:\program files (x86)\windows kits\8.0\include\um\winioctl.h(7277): error C2133: '_STORAGE_QUERY_DEPENDENT_VOLUME_RESPONSE::Lev1Depends' : unknown size

1>c:\program files (x86)\windows kits\8.0\include\um\winioctl.h(7278): error C2133: '_STORAGE_QUERY_DEPENDENT_VOLUME_RESPONSE::Lev2Depends' : unknown size

1>c:\program files (x86)\microsoft directx sdk (june 2010)\include\d3d9types.h(88): error C2467: illegal declaration of anonymous 'struct'

1>c:\program files (x86)\microsoft directx sdk (june 2010)\include\d3d9types.h(2070): error C2467: illegal declaration of anonymous 'struct'
4

1 回答 1

2

Windows 头文件是在考虑这些语言扩展的情况下编写的,如果它们被关闭,它们将无法编译。

您可以做的是重新定义您自己使用的函数和类型,您将能够使用Windows API,而无需包含其标头。然而,这样做是乏味和痛苦的。

于 2012-10-24T19:55:09.967 回答