xinput.h compile errors

Started by
8 comments, last by simon_brown75 12 years, 1 month ago
Hi,

I'm trying to add xbox360 gamepad support to my game, and on inclusion of the xinput.h header file I'm getting no less than 32 errors and 14 warnings, which are listed at the end of this post. I've already searched and found another thread about the same problem, and someone who fixed this by including windows.h in the same file before xinput.h, but this achieves nothing in my case. I already have the paths to the DXSDK lib/include directories setup correctly, and I have xinput.lib included under Project->settings->link->object/library modules. Everything is setup right as far as I can see.

Is it because I'm using VC++6 and if so is there any way I can fix it?

Thanks in advance,
Simon.

C:\PROGRAM FILES\MICROSOFT DIRECTX SDK (JUNE 2010)\INCLUDE\xinput.h(231) : error C2065: '__in' : undeclared identifier
C:\PROGRAM FILES\MICROSOFT DIRECTX SDK (JUNE 2010)\INCLUDE\xinput.h(231) : error C2146: syntax error : missing ')' before identifier 'DWORD'
C:\PROGRAM FILES\MICROSOFT DIRECTX SDK (JUNE 2010)\INCLUDE\xinput.h(231) : warning C4229: anachronism used : modifiers on data are ignored
C:\PROGRAM FILES\MICROSOFT DIRECTX SDK (JUNE 2010)\INCLUDE\xinput.h(233) : error C2059: syntax error : ')'
C:\PROGRAM FILES\MICROSOFT DIRECTX SDK (JUNE 2010)\INCLUDE\xinput.h(237) : error C2146: syntax error : missing ')' before identifier 'DWORD'
C:\PROGRAM FILES\MICROSOFT DIRECTX SDK (JUNE 2010)\INCLUDE\xinput.h(237) : warning C4229: anachronism used : modifiers on data are ignored
C:\PROGRAM FILES\MICROSOFT DIRECTX SDK (JUNE 2010)\INCLUDE\xinput.h(239) : error C2059: syntax error : ')'
C:\PROGRAM FILES\MICROSOFT DIRECTX SDK (JUNE 2010)\INCLUDE\xinput.h(243) : error C2146: syntax error : missing ')' before identifier 'DWORD'
C:\PROGRAM FILES\MICROSOFT DIRECTX SDK (JUNE 2010)\INCLUDE\xinput.h(243) : warning C4229: anachronism used : modifiers on data are ignored
C:\PROGRAM FILES\MICROSOFT DIRECTX SDK (JUNE 2010)\INCLUDE\xinput.h(246) : error C2059: syntax error : ')'
C:\PROGRAM FILES\MICROSOFT DIRECTX SDK (JUNE 2010)\INCLUDE\xinput.h(250) : error C2146: syntax error : missing ')' before identifier 'BOOL'
C:\PROGRAM FILES\MICROSOFT DIRECTX SDK (JUNE 2010)\INCLUDE\xinput.h(250) : warning C4229: anachronism used : modifiers on data are ignored
C:\PROGRAM FILES\MICROSOFT DIRECTX SDK (JUNE 2010)\INCLUDE\xinput.h(250) : error C2182: 'XInputEnable' : illegal use of type 'void'
C:\PROGRAM FILES\MICROSOFT DIRECTX SDK (JUNE 2010)\INCLUDE\xinput.h(251) : error C2059: syntax error : ')'
C:\PROGRAM FILES\MICROSOFT DIRECTX SDK (JUNE 2010)\INCLUDE\xinput.h(255) : error C2146: syntax error : missing ')' before identifier 'DWORD'
C:\PROGRAM FILES\MICROSOFT DIRECTX SDK (JUNE 2010)\INCLUDE\xinput.h(255) : warning C4229: anachronism used : modifiers on data are ignored
C:\PROGRAM FILES\MICROSOFT DIRECTX SDK (JUNE 2010)\INCLUDE\xinput.h(258) : error C2059: syntax error : ')'
C:\PROGRAM FILES\MICROSOFT DIRECTX SDK (JUNE 2010)\INCLUDE\xinput.h(264) : error C2146: syntax error : missing ')' before identifier 'DWORD'
C:\PROGRAM FILES\MICROSOFT DIRECTX SDK (JUNE 2010)\INCLUDE\xinput.h(264) : warning C4229: anachronism used : modifiers on data are ignored
C:\PROGRAM FILES\MICROSOFT DIRECTX SDK (JUNE 2010)\INCLUDE\xinput.h(267) : error C2059: syntax error : ')'
C:\PROGRAM FILES\MICROSOFT DIRECTX SDK (JUNE 2010)\INCLUDE\xinput.h(271) : error C2146: syntax error : missing ')' before identifier 'DWORD'
C:\PROGRAM FILES\MICROSOFT DIRECTX SDK (JUNE 2010)\INCLUDE\xinput.h(271) : warning C4229: anachronism used : modifiers on data are ignored
C:\PROGRAM FILES\MICROSOFT DIRECTX SDK (JUNE 2010)\INCLUDE\xinput.h(274) : error C2059: syntax error : ')'
CInput.cpp
C:\PROGRAM FILES\MICROSOFT DIRECTX SDK (JUNE 2010)\INCLUDE\dinput.h: DIRECTINPUT_VERSION undefined. Defaulting to version 0x0800
C:\PROGRAM FILES\MICROSOFT DIRECTX SDK (JUNE 2010)\INCLUDE\xinput.h(231) : error C2065: '__in' : undeclared identifier
C:\PROGRAM FILES\MICROSOFT DIRECTX SDK (JUNE 2010)\INCLUDE\xinput.h(231) : error C2146: syntax error : missing ')' before identifier 'DWORD'
C:\PROGRAM FILES\MICROSOFT DIRECTX SDK (JUNE 2010)\INCLUDE\xinput.h(231) : warning C4229: anachronism used : modifiers on data are ignored
C:\PROGRAM FILES\MICROSOFT DIRECTX SDK (JUNE 2010)\INCLUDE\xinput.h(233) : error C2059: syntax error : ')'
C:\PROGRAM FILES\MICROSOFT DIRECTX SDK (JUNE 2010)\INCLUDE\xinput.h(237) : error C2146: syntax error : missing ')' before identifier 'DWORD'
C:\PROGRAM FILES\MICROSOFT DIRECTX SDK (JUNE 2010)\INCLUDE\xinput.h(237) : warning C4229: anachronism used : modifiers on data are ignored
C:\PROGRAM FILES\MICROSOFT DIRECTX SDK (JUNE 2010)\INCLUDE\xinput.h(239) : error C2059: syntax error : ')'
C:\PROGRAM FILES\MICROSOFT DIRECTX SDK (JUNE 2010)\INCLUDE\xinput.h(243) : error C2146: syntax error : missing ')' before identifier 'DWORD'
C:\PROGRAM FILES\MICROSOFT DIRECTX SDK (JUNE 2010)\INCLUDE\xinput.h(243) : warning C4229: anachronism used : modifiers on data are ignored
C:\PROGRAM FILES\MICROSOFT DIRECTX SDK (JUNE 2010)\INCLUDE\xinput.h(246) : error C2059: syntax error : ')'
C:\PROGRAM FILES\MICROSOFT DIRECTX SDK (JUNE 2010)\INCLUDE\xinput.h(250) : error C2146: syntax error : missing ')' before identifier 'BOOL'
C:\PROGRAM FILES\MICROSOFT DIRECTX SDK (JUNE 2010)\INCLUDE\xinput.h(250) : warning C4229: anachronism used : modifiers on data are ignored
C:\PROGRAM FILES\MICROSOFT DIRECTX SDK (JUNE 2010)\INCLUDE\xinput.h(250) : error C2182: 'XInputEnable' : illegal use of type 'void'
C:\PROGRAM FILES\MICROSOFT DIRECTX SDK (JUNE 2010)\INCLUDE\xinput.h(251) : error C2059: syntax error : ')'
C:\PROGRAM FILES\MICROSOFT DIRECTX SDK (JUNE 2010)\INCLUDE\xinput.h(255) : error C2146: syntax error : missing ')' before identifier 'DWORD'
C:\PROGRAM FILES\MICROSOFT DIRECTX SDK (JUNE 2010)\INCLUDE\xinput.h(255) : warning C4229: anachronism used : modifiers on data are ignored
C:\PROGRAM FILES\MICROSOFT DIRECTX SDK (JUNE 2010)\INCLUDE\xinput.h(258) : error C2059: syntax error : ')'
C:\PROGRAM FILES\MICROSOFT DIRECTX SDK (JUNE 2010)\INCLUDE\xinput.h(264) : error C2146: syntax error : missing ')' before identifier 'DWORD'
C:\PROGRAM FILES\MICROSOFT DIRECTX SDK (JUNE 2010)\INCLUDE\xinput.h(264) : warning C4229: anachronism used : modifiers on data are ignored
C:\PROGRAM FILES\MICROSOFT DIRECTX SDK (JUNE 2010)\INCLUDE\xinput.h(267) : error C2059: syntax error : ')'
C:\PROGRAM FILES\MICROSOFT DIRECTX SDK (JUNE 2010)\INCLUDE\xinput.h(271) : error C2146: syntax error : missing ')' before identifier 'DWORD'
C:\PROGRAM FILES\MICROSOFT DIRECTX SDK (JUNE 2010)\INCLUDE\xinput.h(271) : warning C4229: anachronism used : modifiers on data are ignored
C:\PROGRAM FILES\MICROSOFT DIRECTX SDK (JUNE 2010)\INCLUDE\xinput.h(274) : error C2059: syntax error : ')'
Advertisement
Ok, I tried the same code in Visual Sutido 2010 express - no problems at all, so yes it does look like some issue with VC++6, which I know isn't supported anymore with the DirectX SDK. However, I'd really appreciate if someone could help me understand those errors and get the code (basically any code that includes xinput.h) to compile under VC++6, because I really don't have the £650+ to buy VS10, and the free or the academic versions are no use should I ever want to sell my game, plus I already paid for VC6 Pro. Plus VS10 seems so much more bloated to me.
Ok I solved this. I don't know where the definition of __in __out and __reserved are supposed to be, they don't seem to be in windef.h (the only header file included in xinput.h), or windows.h, but just by defining them myself I got the code to compile. They're just stupid microsoft macros, more or less just comments.

#define __in
#define __out
#define __reserved
#include <xinput.h>


This works under VC++ 6
Those are SAL Annotations, and are located in sal.h. SAL wasn't around back when VC++ 6 came out, which is why you don't have that header. Officialy, the DirectX SDK requires at least VS 2008 SP1. So I would suspect that this would just be the first of many problems you'll encounter while trying to get it to work with such an old compiler + Windows SDK. What exactly is it that you need from the paid versions of VS 2010?
Thank you for the info.

I'm guessing the Express version of VS2010 produces unoptimized code, and I wouldn't be able to legally sell anything made with the academic version. I think I'll stick with VC6 for now, at least until I hit an insurmountable problem with it.

I'm guessing the Express version of VS2010 produces unoptimized code...

You're guessing incorrectly. VS6 does not even compile C++ code, which I would consider an insurmountable problem. You may, of course, make your own choices.

Stephen M. Webb
Professional Free Software Developer

Err..... in what way does VC++ 6 not compile C++ code? I can only assume you mean there's been some changes to the C++ language since VS6 was released?

Err..... in what way does VC++ 6 not compile C++ code? I can only assume you mean there's been some changes to the C++ language since VS6 was released?

For one:

for(int i=0; i<10; ++i)
printf("This compiles...\n");
for(int i=0; i<10; ++i)
printf("This does not.\n");

(I.e. scope rules on loops are knackered). VC6's STL has a number of security and performance issues with it, you need the Professional edition or above before it does any optimisation, it can't support 64-bit targets, and a number of other issues I can't recall offhand. That, and using a compiler / IDE that's 14 years old makes me twitch a lot.

For your own sanity, I strongly suggest upgrading to VS2010 unless you have a significant reason not to (Such as you're working with hardware / libraries that are limited to VC6 for some reason, or you have hundreds of project files you'd need to update). It's free, you can sell anything you make with it, and it produces safer, faster code than VC6.
The express version of VC++ 2010 supports code and linker optimizations. What it doesn't support is 64-bit compilation targets, the ability to run add-ins/plugins, as well some advanced features like unit tests, profiling, and team server. It also doesn't include ATL and MFC. There's a comparison chart here.
Well I'm not one to ignore advice, so I will switch to VS2010 express and see how I get on. For the record I don't need any of that stuff the express version is missing.

Thanks guys.

This topic is closed to new replies.

Advertisement