So I have gcc version 4.8.1, g++ version 4.6.4, using flags: -std=c++0x and -pthread.
I simplified my problem down to the code shown and still get the original error.
What I have below compiles, but when I uncomment the two lines for thread "two", I get the error message shown below the code
#include <iostream>
#include <thread>
using namespace std;
void print_int(int x=7);
void print_A(){
cout << "A\n";
}
int main(){
thread one (print_int,17);
//thread two (print_int);
thread three (print_A);
one.join();
//two.join();
three.join();
return 0;
}
void print_int(int x){
cout << x << '\n';
}
I tried to parse through the error messages but I still have no clue what's going on...
In file included from /usr/include/c++/4.6/thread:39:0,
from def_params.cpp:2:
/usr/include/c++/4.6/functional: In member function ‘void std::_Bind_result<_Result, _Functor(_Bound_args ...)>::__call(std::tuple<_Args ...>&&, std::_Index_tuple<_Indexes ...>, typename std::_Bind_result<_Result, _Functor(_Bound_args ...)>::__enable_if_void<_Res>::type) [with _Res = void, _Args = {}, int ..._Indexes = {}, _Result = void, _Functor = void (*)(int), _Bound_args = {}, typename std::_Bind_result<_Result, _Functor(_Bound_args ...)>::__enable_if_void<_Res>::type = int]’:
/usr/include/c++/4.6/functional:1378:24: instantiated from ‘std::_Bind_result<_Result, _Functor(_Bound_args ...)>::result_type std::_Bind_result<_Result, _Functor(_Bound_args ...)>::operator()(_Args&& ...) [with _Args = {}, _Result = void, _Functor = void (*)(int), _Bound_args = {}, std::_Bind_result<_Result, _Functor(_Bound_args ...)>::result_type = void]’
/usr/include/c++/4.6/thread:117:13: instantiated from ‘void std::thread::_Impl<_Callable>::_M_run() [with _Callable = std::_Bind_result<void, void (*())(int)>]’
def_params.cpp:26:9: instantiated from here
/usr/include/c++/4.6/functional:1287:4: error: too few arguments to function
Any suggestions or solutions? Thanks in advance!