Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: warning comparison beetwen enums  (Read 5626 times)

0 Members and 2 Guests are viewing this topic.

amdlintuxos

  • Newbie
  • *
  • Posts: 17
    • View Profile
warning comparison beetwen enums
« on: June 25, 2011, 10:27:58 pm »
Greeting all.
Actually that is not a big issue (code works fine), but compiler(g++) gives me a warnings and i have feeling that i am doing something not exactly correct.


Code: [Select]

        if (g_EVENT.Type == sf::Event::MouseButtonPressed)
        {
           if (g_EVENT.Key.Code == sf::Mouse::Left)              
              g_MOUSE_LEFT_BUTTON = true;

           if (g_EVENT.Key.Code == sf::Mouse::Right)
              g_MOUSE_RIGHT_BUTTON = true;
        }

And here what compilers says.

Quote

keyEventsInSpace.cpp:190:47: warning: comparison between ‘enum sf::Key::Code’ and ‘enum sf::Mouse::Button’
keyEventsInSpace.cpp:193:47: warning: comparison between ‘enum sf::Key::Code’ and ‘enum sf::Mouse::Button’


I know that is just a warnings and i may switched off those, but i am new in C++ and want to learn how to do things right.


Many thanks for attention in advance.

OniLinkPlus

  • Hero Member
  • *****
  • Posts: 500
    • View Profile
warning comparison beetwen enums
« Reply #1 on: June 26, 2011, 01:37:14 am »
Event.Key is for KEYBOARD events, not Mouse events. Use Event.MouseButton instead.
I use the latest build of SFML2

amdlintuxos

  • Newbie
  • *
  • Posts: 17
    • View Profile
warning comparison beetwen enums
« Reply #2 on: June 26, 2011, 10:53:44 am »
OniLink10
Thanks, that solved my problem.
Quote

if (g_EVENT.MouseButton.Button == sf::Mouse::Left)