Reputation: 187
I'm trying to go through the XInput tutorial at http://msdn.microsoft.com/en-us/library/windows/desktop/ee417001%28v=vs.85%29.aspx. However, the code from the example won't even execute because it keeps saying that, among other errors, "No Target Architecture". I've looked all over the internet and still have no idea how to define my architecture. All I'm looking to do right now is have the program tell me if a controller is connected or not. Here is the code I have so far:
#include <Xinput.h>
#include <Windows.h>
void main(){
DWORD dwResult;
// Retrieve the state of the controller
for (DWORD i = 0; i < XUSER_MAX_COUNT; i++)
{
XINPUT_STATE state;
ZeroMemory(&state, sizeof(XINPUT_STATE));
// Simply get the state of the controller from XInput.
dwResult = XInputGetState(i, &state);
if (dwResult == ERROR_SUCCESS){
// Controller is connected
}
else
{
// Controller is not connected
}
}
}
I'm running Windows 7 Professional 64-bit and using Visual Studio Professional 2013. Here are my errors (project path removed for space):
1 error C1189: #error : "No Target Architecture" c:\program files (x86)\windows kits\8.1\include\um\winnt.h 145 1
2 IntelliSense: #error directive: "No Target Architecture" c:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h 145 2
3 IntelliSense: identifier "PCONTEXT" is undefined c:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h 16918 11
4 IntelliSense: identifier "PSLIST_HEADER" is undefined c:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h 17529 11
5 IntelliSense: identifier "SLIST_HEADER" is undefined c:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h 17537 16
6 IntelliSense: identifier "PSLIST_HEADER" is undefined c:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h 17544 13
7 IntelliSense: identifier "PSLIST_HEADER" is undefined c:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h 17551 13
8 IntelliSense: identifier "PSLIST_HEADER" is undefined c:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h 17559 13
9 IntelliSense: identifier "PSLIST_HEADER" is undefined c:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h 17569 13
10 IntelliSense: identifier "PSLIST_HEADER" is undefined c:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h 17576 10
11 IntelliSense: identifier "PCONTEXT" is undefined c:\Program Files (x86)\Windows Kits\8.1\Include\um\minwinbase.h 358 9
12 IntelliSense: identifier "PSLIST_HEADER" is undefined c:\Program Files (x86)\Windows Kits\8.1\Include\um\interlockedapi.h 51 11
13 IntelliSense: identifier "PSLIST_HEADER" is undefined c:\Program Files (x86)\Windows Kits\8.1\Include\um\interlockedapi.h 59 13
14 IntelliSense: identifier "PSLIST_HEADER" is undefined c:\Program Files (x86)\Windows Kits\8.1\Include\um\interlockedapi.h 67 13
15 IntelliSense: identifier "PSLIST_HEADER" is undefined c:\Program Files (x86)\Windows Kits\8.1\Include\um\interlockedapi.h 81 13
16 IntelliSense: identifier "PSLIST_HEADER" is undefined c:\Program Files (x86)\Windows Kits\8.1\Include\um\interlockedapi.h 94 13
17 IntelliSense: identifier "PSLIST_HEADER" is undefined c:\Program Files (x86)\Windows Kits\8.1\Include\um\interlockedapi.h 102 10
18 IntelliSense: identifier "CONTEXT" is undefined c:\Program Files (x86)\Windows Kits\8.1\Include\um\processthreadsapi.h 762 16
19 IntelliSense: identifier "PCONTEXT" is undefined c:\Program Files (x86)\Windows Kits\8.1\Include\um\WinBase.h 1279 14
20 IntelliSense: identifier "PCONTEXT" is undefined c:\Program Files (x86)\Windows Kits\8.1\Include\um\WinBase.h 8619 13
21 IntelliSense: identifier "PCONTEXT" is undefined c:\Program Files (x86)\Windows Kits\8.1\Include\um\WinBase.h 8621 10
22 IntelliSense: identifier "PCONTEXT" is undefined c:\Program Files (x86)\Windows Kits\8.1\Include\um\WinBase.h 8637 11
23 IntelliSense: identifier "PCONTEXT" is undefined c:\Program Files (x86)\Windows Kits\8.1\Include\um\WinBase.h 8660 10
24 IntelliSense: identifier "PCONTEXT" is undefined c:\Program Files (x86)\Windows Kits\8.1\Include\um\WinBase.h 8669 10
25 IntelliSense: identifier "PCONTEXT" is undefined c:\Program Files (x86)\Windows Kits\8.1\Include\um\WinBase.h 8685 13
Furthermore, I've included the code for the first error. Line 145 is the line that says "No Target Architecture". There is a red line underneath "#error". Here it is:
#if defined(_AMD64_) || defined(_X86_)
#define PROBE_ALIGNMENT( _s ) TYPE_ALIGNMENT( DWORD )
#elif defined(_IA64_) || defined(_ARM_)
#define PROBE_ALIGNMENT( _s ) (TYPE_ALIGNMENT( _s ) > TYPE_ALIGNMENT( DWORD ) ? \
TYPE_ALIGNMENT( _s ) : TYPE_ALIGNMENT( DWORD ))
#elif !defined(RC_INVOKED)
#error "No Target Architecture"
#endif
Thanks for your help in advance. Myself and a couple other guys are having trouble with this, so any help would be appreciated.
Upvotes: 0
Views: 2111
Reputation: 131
If I understand this correctly, you need to define the architecture of the platform your program will be running on. so put #define _AMD64_
for example, before your includes.
If that does not help, maybe you need to add some libraries to your compiler dependency...that solved my problem.
And IIRC putting #include<windows.h>
in front of #include<Xinput.h>
might help as well.
Upvotes: 3