XInputGetState has to be assigned to to a variable

I've just started following the series. I've had no real problems, and I've now run into a massive roadblock. My code stopped working after Casey implmented the new function definitions, and I couldn't compile. I then, through pure luck, discovered a "fix". I have to write
1
auto r = XInputGetState(ControllerIndex, &ControllerState);
and then
1
if (r(ControllerIndex, &ControllerState) == ERROR_SUCCESS)
when I call the function in the loop

I have no idea why this is happening. I even tried copying the function definition from the episode guide.
Here's the definition of the function
1
2
3
4
5
6
7
#define X_INPUT_GET_STATE(name) DWORD WINAPI name(DWORD dwUserIndex, XINPUT_STATE *pState)
typedef X_INPUT_GET_STATE(x_input_get_state);
X_INPUT_GET_STATE(XInputGetStateStub) {
	return 0;
}
global_variable x_input_get_state *XInputGetState_ = XInputGetStateStub;
#define XInputGetState XInputGetState_;


I have nailed the problem down to the #define. The program compiles with this line
1
if (XInputGetState_(ControllerIndex, &ControllerState) == ERROR_SUCCESS)
but fails with this line
1
if (XInputGetState(ControllerIndex, &ControllerState) == ERROR_SUCCESS)


My #define looks like this
1
#define XInputGetState XInputGetState_;

Edited by Rasmus on
If you use this define" #define XInputGetState XInputGetState_;" then code like this:
1
if (XInputGetState(ControllerIndex, &ControllerState) == ERROR_SUCCESS)

expands to code like this:
1
if (XInputGetState_;(ControllerIndex, &ControllerState) == ERROR_SUCCESS)

Which is a syntax error. Remove the semicolon. Remember that preprocessor is just a text replacement, it's not C statements, just a text.

You should really post exact error message if you are asking for help. Error message would exactly say what is the problem.

Edited by Mārtiņš Možeiko on
I really should've seen that. Thanks.

Regarding the error code. I usually do that, and I now feel stupid for not including it this time.