1 2 3 4 5 6 7 8 9 10 11 12 13 | for (DWORD ControllerIndex = 0; ControllerIndex < XUSER_MAX_COUNT; ++ControllerIndex) { XINPUT_STATE ControllerState; if(XInputGetState(ControllerIndex, &ControllerState) == ERROR_SUCCESS) { XINPUT_GAMEPAD *Pad = &ControllerState.Gamepad; int16 StickX = Pad->sThumbLX; int16 StickY = Pad->sThumbLY; } } |
we created local variables StickX and StickY which simply store the values of the variables in the Pad Struct. my question is, will the compiler actually push space for StickX and StickY on the stack if all we ever do is read from them, or would MSVC be intelligent enough to know that StickX and StickY simply refer to Pad's members, in order to save space on the stack (this is assuming these ints aren't stored in registers for the entirety of the function and actually need to be loaded from memory at some point)?