Question

I'm trying to write a singleton class to hold the state of inputs from the user (mouse/keyboard data). The SDL API returns keyboard data as Uint8 pointer array, however, why I try to create the Uint8 pointer, I get these errors at the line w/ the uint8:

error C2143: syntax error : missing ';' before '*'

error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

I've used Uint8 as a data type without defining it before, so I'm not sure what is causing the issue here. Here is my code:

class InputState {
public:

    InputState()
    {};
    ~InputState()
    {};


    static InputState *getInputState(void)
    {
        static InputState *state = new InputState();

        return state;
    };

public:
    Uint8 *keys;

    struct MouseState
    {
        int LeftButtonDown;
        int RightButtonDown;
        int MiddleButtonDown;

        int x;
        int y;

        MouseState ()
        {
            LeftButtonDown = 0;
            RightButtonDown = 0;
            MiddleButtonDown = 0;

            x = 0;
            y = 0;
        }
    };

    MouseState *mouseState;
};
Was it helpful?

Solution

The type Uint8 is a typedef that is defined in one of the SDL header. If you want to use it, you need to include the SDL.h header in your file.

// You need this include if you want to use SDL typedefs
#include <SDL.h>

class InputState {
public:

    InputState()
    {};
    ~InputState()
    {};

    // ...

public:
    Uint8 *keys;

    // ...
};
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top