是否可以编写带有语言扩展名的windows和directx代码?

时间:2012-10-24 19:43:55

标签: c++ windows directx-9 language-extension

我的项目有扩展,但必须打开任何包含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'

1 个答案:

答案 0 :(得分:2)

Windows标头在编写时考虑了这些语言扩展,如果关闭它们将无法编译。

您可以做的是重新定义您自己使用的功能和类型,并且您将能够使用 Windows API 而不包括其标题。但是,这样做既乏味又痛苦。