Code does not compile in C++11

Asked

Viewed 61 times

2

I have a common code, more specifically the following:

#include <iostream>
#include <SFML/System.hpp>
#include <SFML/Window/Keyboard.hpp>

namespace thread
{
    void check_key(sf::Keyboard::Key key)
    {
        while(true)
        {
            if(sf::Keyboard::isKeyPressed(key))
            {
                exit(EXIT_SUCCESS);
            }
        }
    }
}

int main()
{
    sf::Thread keycheck(&thread::check_key, sf::Keyboard::Escape);
    keycheck.launch();
    while(true)
        std::cout << "Hello! ";
}

And when I compile in Code::Blocks, with SFML 2.0’s Wizzard, it works correctly (comes out when ESC tightens). I went to change the sf::Thread for std::thread of course: I first activated C++11. Just to see if it ran, I tried to compile. Mingw returned several errors, for example, ::diftime and other entities only of <ctime>. What should I do?

  • Can you give more details about the error? And which compiler are you using? I’ve seen some versions of gcc (mainly the ones before 4.8.0) that made a lot of mistakes with C++11.

  • @Lucasnunes GCC (Mingw) 4.8.1. I found that the problem is not SFML, but actually the <ctime> + C++11.

1 answer

0


The problem was probably a corrupted file. The solution is to uninstall the compiler and install it again.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.