Pregunta

I've got extensions off on my project but have to turn them on for any cpp file that includes directx or windows headers.

If I turn extensions off on those cpp files it won't compile. Is there a way to get this to work?

With language extensions on it compiles fine.

I'm using VS2012 express, c++, directx9, and Win7 64.

Example errors

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'
¿Fue útil?

Solución

The Windows headers are written with those language extensions in mind, and they will fail to compile if they are turned off.

What you can do is redefine the functions and types you use yourself and you will be able to work with the Windows API without including its headers. However, this is tedious and painful to do.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top