C++0x <thread> header: std::this_thread::sleep_for is missing. _GLIBCXX_USE_NANOSLEEP not correctly set.
I’m currently trying to compile a C++0x program with
The compilation fails because the std::this_thread::sleep_for function is missing.
This standard function is supposed to be found in the <thread> header provided by the above mentioned package in /usr/gcc/4.6/include/c++/4.6.2/thread.
As this sleep_for function is implemented with nanosleep, it’s definition is conditioned by _GLIBCXX_USE_NANOSLEEP.
This macro is defined (or not) in /usr/gcc/4.6/include/c++/4.6.2/i386-pc-solaris2.11/[amd64/]bits/c++config.h
Currently, this _GLIBCXX_USE_NANOSLEEP macro is not defined (hence the error about std::this_thread::sleep_for) presumably because libc.so does not provide nanosleep (the nanosleep symbol it contains is protected).
But, on OpenIndiana, nanosleep is provided by librt.so.
As a consequence, provided the program is linked with -lrt, nanosleep exists and std::this_thread::sleep_for can be defined.
I’m currently compiling my program with -D_GLIBCXX_USE_NANOSLEEP=1, but it is not really clean. Could you check whether c++config.h shouldn’t define it ?