Jump to content
  • Advertisement
Sign in to follow this  
Funkyjive

Passing SDL event as parameter error

This topic is 3784 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello again everyone. I keep getting an error when trying to compile in vs2008. I cant decipher what the error is trying to tell me to fix. Here is the error... 1>Keyboard.obj : error LNK2019: unresolved external symbol "public: int __thiscall Keyboard::ParseKey(union SDL_Event)" (?ParseKey@Keyboard@@QAEHTSDL_Event@@@Z) referenced in function "public: void __thiscall Keyboard::ParseEvent(union SDL_Event)" (?ParseEvent@Keyboard@@QAEXTSDL_Event@@@Z) Im not really sure what this is trying to tell me? So is it complaining that im passing an SDL event as a parameter of those functions or what? I am calling the ParseEvent function from inside the game engine and passing the event (this way I can do all of my keyboard/mouse input in a single SDL_PollEvent). The ParseEvent function then calls ParseKey handing down the event. the ParseKey is a way for me to translate the values representing the keys sdl declared into a number for my arrays that keep track of the key state. In case it is useful here is the keyboard header file...
#pragma once
#include <SDL/SDL.h>

//Ommited my custom key declarations 0-62 coresponding to a place in the array

class Keyboard
{
    private:
		bool keylast[62];
		bool keythis[62];

		void KeyUp(int key);
		void KeyDown(int key);

	public:
		Keyboard();

		void Update();
		bool Pressed(int key);
                bool Press(int key);
                bool Release(int key);

		void ParseEvent(SDL_Event theevent);
		int ParseKey(SDL_Event theevent);
};
Thanks in advance!

Share this post


Link to post
Share on other sites
Advertisement
Suggestion: change
void ParseEvent(SDL_Event theevent);

to
void ParseEvent(SDL_Event &theevent);

In other words, try using pass-by-reference instead

Note that the SDL_Event class is actually a union, so the linker is having trouble binding the function call to the function itself.

Share this post


Link to post
Share on other sites

int ParseKey(SDL_Event theevent)
{
switch (theevent.key.keysym.sym)
{
case SDLK_a:
return 0;
case SDLK_b:
return 1;
case SDLK_c:
return 2;

////Omitted for space but u get the idea

default:
break;
}
return (-1);
}

Share this post


Link to post
Share on other sites
I changed it to &theevent and I still get this error...

1>Keyboard.obj : error LNK2019: unresolved external symbol "public: int __thiscall Keyboard::ParseKey(union SDL_Event &)" (?ParseKey@Keyboard@@QAEHAATSDL_Event@@@Z) referenced in function "public: void __thiscall Keyboard::ParseEvent(union SDL_Event &)" (?ParseEvent@Keyboard@@QAEXAATSDL_Event@@@Z)

Share this post


Link to post
Share on other sites
Look at the function name in the error - it is expecting a member function, not a free function.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!