cwindowsxinput

Compiler won't accept valid code? error C2447: '{': missing function header (old-style formal list?)


Just want to start by saying thank you for taking the time to look at my problem.

Below is the code that is giving me the error:

// INFO(Tanner): XInputGetState Support
#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(ERROR_DEVICE_NOT_CONNECTED);
}
global_variable x_input_get_state* XInputGetState_ = XInputGetStateStub;
#define XInputGetState XInputGetState_


// INFO(Tanner): XInputSetState Support
#define X_INPUT_SET_STATE(name) DWORD WINAPI name(DWORD dwUserIndex, XINPUT_VIBRATION* pVibration);
typedef X_INPUT_SET_STATE(x_input_set_state);

X_INPUT_SET_STATE(XInputSetStateStub)
{
    return(0);
}
global_variable x_input_set_state* XInputSetState_ = XInputSetStateStub;
#define XInputSetState XInputSetState_

The problem accoring to the compiler is that I don't have the open currly brace "{" for my XInputGetStateStub and XInputSetStateStub.

Any help is appriciated!


Solution

  • Your code will preprocess to the following:

    typedef DWORD WINAPI x_input_get_state(DWORD dwUserIndex, XINPUT_STATE* pState);;
    
    DWORD WINAPI XInputGetStateStub(DWORD dwUserIndex, XINPUT_STATE* pState);
    {
        return(ERROR_DEVICE_NOT_CONNECTED);
    }
    global_variable x_input_get_state* XInputGetState_ = XInputGetStateStub;
    
    typedef DWORD WINAPI x_input_set_state(DWORD dwUserIndex, XINPUT_VIBRATION* pVibration);;
    
    DWORD WINAPI XInputSetStateStub(DWORD dwUserIndex, XINPUT_VIBRATION* pVibration);
    {
        return(0);
    }
    global_variable x_input_set_state* XInputSetState_ = XInputSetStateStub;
    

    As you can see there is an extra ; after the DWORD WINAPI XInputSetStateStub(DWORD dwUserIndex, XINPUT_VIBRATION* pVibration) due to #define ending with a ;. Remove that, and see if it works or not.