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

Author Topic: sf::Clock does not work  (Read 1996 times)

0 Members and 1 Guest are viewing this topic.

phufhi

  • Newbie
  • *
  • Posts: 8
    • View Profile
sf::Clock does not work
« on: September 09, 2012, 03:51:10 pm »
Recently I got the newest version of SFML 2, but I couldn't get sf::Clock to work.
This code produces the error:
#include <SFML/Graphics.hpp>

int main()
{
    sf::Clock clock();
    sf::Time time = clock.getElapsedTime();

    return 0;
}

The compiler tells me this:
error: request for member 'getElapsedTime' in 'clock', which is of non-class type 'sf::Clock()'

note:
This does also not work with <SFML/System.hpp>

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: sf::Clock does not work
« Reply #1 on: September 09, 2012, 03:54:41 pm »
Does that work:

#include <SFML/System.hpp>

int main()
{
    sf::Clock clock;
    sf::Time time = clock.getElapsedTime();

    return 0;
}
« Last Edit: September 09, 2012, 03:56:33 pm by eXpl0it3r »
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

phufhi

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: sf::Clock does not work
« Reply #2 on: September 09, 2012, 03:59:59 pm »
Thanks, this works!
I have no idea how I missed this (it's in the documentation and my previous programs)...