Jump to content
  • Advertisement
Sign in to follow this  
noatom

No target arhitecture error

This topic is 2165 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
#include <Windows>
#include <XInput.h>


void GamePad::check_connection(){
	for(DWORD i = 0; i < XUSER_MAX_COUNT && controllerID == -1;i++){
		XINPUT_STATE state;
		ZeroMemory(&state, sizeof(XINPUT_STATE));
		if(XInputGetState(i,&state) == ERROR_SUCCESS)
			controllerID = i;
	}
}

i have no ideea what could cause this

Share this post


Link to post
Share on other sites

There's a thread about it on MSDN here http://social.msdn.microsoft.com/Forums/vstudio/en-US/c88faa9b-3d66-4586-a2ec-6f1a6e34c882/win64-error-no-target-architecture?forum=vcgeneral but I couldn't see a definitive answer.

 

My solution would be this:

#include <Windows>
#include <XInput.h>


void GamePad::check_connection(){
	for(DWORD i = 0; i < XUSER_MAX_COUNT && controllerID == -1;i++){
		XINPUT_STATE state = {0}; // Does same thing as ZeroMemory
		//ZeroMemory(&state, sizeof(XINPUT_STATE));
		if(XInputGetState(i,&state) == ERROR_SUCCESS)
			controllerID = i;
	}
}

and let the compiler do it for you.

Edited by Paradigm Shifter

Share this post


Link to post
Share on other sites

I always use that method to zero out structs on the stack. Maybe ZeroMemory can be slightly more optimised, I dunno, but surely the compiler can optimise it anyway? You'd have to look at the assembly output to see if there are any differences.

 

The = {0} thing always works if the struct has no constructors defined and is portable, and doesn't rely on macros or function calls. The reason it works is that if you don't initialise all members of a struct (or array) (EDIT: but you do provide an initialiser for at least one field) the rest get zero initialised, so if you zero initialise the first member everything gets zeroed.

Edited by Paradigm Shifter

Share this post


Link to post
Share on other sites

I always use that method to zero out structs on the stack. Maybe ZeroMemory can be slightly more optimised, I dunno, but surely the compiler can optimise it anyway? 

ZeroMemory is a macro that wraps memset.

 

{0} will try to call default constructors of the members. So the *code speed* depends on the structure.

Edited by imoogiBG

Share this post


Link to post
Share on other sites
Non-POD structs and classes should have constructors anyway, so they should be designed to have initialized members on construction.

Share this post


Link to post
Share on other sites

Not if you want your API to be compatible with C, which can be important. Win32 is all C anyway, even the COM (ActiveX) stuff has C bindings via macros.

 

You can use the preprocessor to exclude constructors and other C++ related stuff from C builds anyway.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!