dimanche 28 juin 2015

std::thread missing type specifier

I am trying to use an c++11 thread with lambda functions. I already use it on another class, but for some reason on my LogManager static class i have some weird problems.

My "minimal" class is:

#include <iostream>
#include <fstream>
#include <map>
#include <vector>
#include <algorithm>
#include <thread>

using namespace std;
namespace Debug {
    enum LogLevel{
        ERROR, /*!< Mensagens de erro. */
        WARNING, /*!< Mensagens de alerta. */
        MESSAGE, /*!< Mensagens gerais, normalmente utilizadas para propositos de debug. */
        UNKNOWN /*!< Mensagems de de origem desconhecidas, normalmente utilizadas em exceptions */
    };
    class LogManager{

    public:
        template<typename T, typename... Args>
        static void log(LogLevel logLevel, const char *string, T value = "", Args... args){

            std::thread t([=](){
                std::cout << "thread function\n";
            });


        }
    };
}

When i try to compile i get some:

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

It dont seems to be a compiler problem, i have the "same" code on another class, it seems to be something i forgot, i dont know if an static class can be a problem.

Thanks

Aucun commentaire:

Enregistrer un commentaire