Everything worked and compiled fine until I
test.cpp:173:33: error: no matching function for call to
‘std::thread::thread(, int, int,
std::thread t1(read, 1, 0, 3),
^ test.cpp:173:33: note: candidates are: In file included from test.cpp:6:0:
/usr/include/c++/4.8/thread:133:7: note: template std::thread::thread(_Callable&&, _Args&& ...)
thread(_Callable&& __f, _Args&&... __args)
[200 more similar lines]
std::thread t1(read, 1, 0, 3)
You pass a function pointer to the function
read to the constructor of
unistd.h declares the function:
ssize_t read(int, void *, size_t).
As can be seen from the error message, you have overloads for the
read function. The one that you used before including unistd.h is not the same as what unistd.h declares. An overloaded function cannot be implicitly converted into a function pointer, because the compiler cannot know which
read function you intended to use.
You can explicitly cast the identifier to a function pointer of correct type to resolve the ambiguity.