【问题标题】:Is it possible to write windows and directx code with language extensions off?是否可以在关闭语言扩展的情况下编写 windows 和 directx 代码?
【发布时间】:2012-10-24 19:43:55
【问题描述】:

我在我的项目中关闭了扩展,但必须为任何包含 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'

【问题讨论】:

  • 向问题添加错误消息
  • 顺便说一句,添加的错误消息只是来自使用 directx 的 cpp 文件,Windows 标头会给出其他错误
  • MinGW 有一些重新制作的 DirectX9 标头,可以与 GCC 一起使用,我能够成功使用。

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


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 2018-06-30
    • 2015-03-22
    • 2013-01-15
    • 2010-09-05
    • 2016-08-31
    • 2019-02-12
    • 1970-01-01
    • 1970-01-01
    • 2012-12-13
    相关资源
    最近更新 更多