title: C++ XInput Compilation using g++
body: <pre><code>#include &lt;Windows.h&gt;
  #include &lt;XInput.h&gt;
  
  #include &lt;iostream&gt;
  
  using namespace std;
  
  struct Controller{
      XINPUT_STATE state;
  };
  
  class Joypad
  {
  public:
      int getJoystickPort()
      {
          DWORD dwResult;
  
          for (DWORD i = 0; i &lt; XUSER_MAX_COUNT; i++)
          {
              XINPUT_STATE state;
              ZeroMemory(&amp;state, sizeof(XINPUT_STATE));   
  
              // Simply get the state of the controller from XInput.
              dwResult = XInputGetState(i, &amp;state);
  
              if (dwResult == ERROR_SUCCESS)
              {
                  return((int) i);
                  cout &lt;&lt; "Joystick Port: " &lt;&lt; i &lt;&lt; " is connnected." &lt;&lt; endl;
                  cout &lt;&lt; "Button " &lt;&lt; (((int)state.Gamepad.wButtons == XINPUT_GAMEPAD_A)) &lt;&lt; " pressed." &lt;&lt; endl;
                  cout &lt;&lt; "LX:  " &lt;&lt; state.Gamepad.sThumbLX &lt;&lt; " LY: " &lt;&lt; state.Gamepad.sThumbLY &lt;&lt; endl;
                  cout &lt;&lt; "RX:  " &lt;&lt; state.Gamepad.sThumbRX &lt;&lt; " RY: " &lt;&lt; state.Gamepad.sThumbRY &lt;&lt; endl;
              }
              else
              {
                  cout &lt;&lt; "Joystick at Port: " &lt;&lt; i &lt;&lt; " is disconnected." &lt;&lt; endl;
              }
          }
          return -1;
      }
  };
  
  
  
  void joystickStates(){
      Joypad* joypad = new Joypad;
      while (true){
          system("cls");      
          joypad-&gt;getJoystickPort();
          Sleep(1000);
      }
  }
  
  int main(){
      joystickStates();
      return 0;
  }
  </code></pre>
  
  <p>im getting the __in &amp; __out 's was not declared in this scope errors.</p>
  
  <p>I used the syntax below g++ Joypad.cpp -IC:\DirectSDK\Include -LC:\DirectSDK\Lib\x86 -lXinput -o Joypad</p>
  
  <p>and I also tried 
  g++ Joypad.cpp -IC:\Windows SDK~um,shared, etc -LC:\Windows SDK\Lib -lXInput -o Joypad</p>
  
  <p>Is there something I missed? I use mingw x86_64</p>
  
  <blockquote>
    <p>Directories included:
        Windows Kits 8.1 (um,shared,winrt)
        Microsoft DirectX SDK</p>
    
    <p>Libraries included: XInput.lib - C:\Progra~2\Micros~4\Lib\x86</p>
  </blockquote>