Project

General

Profile

Actions

Bug #1851

closed

C++0x <thread> header: std::this_thread::sleep_for is missing. _GLIBCXX_USE_NANOSLEEP not correctly set.

Added by Lénaïc Huard about 10 years ago. Updated almost 9 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Start date:
2011-12-04
Due date:
% Done:

0%

Estimated time:
Difficulty:
Medium
Tags:
needs-triage

Description

Hello,

I’m currently trying to compile a C++0x program with
pkg: (sfe)

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 ?

Actions #1

Updated by Andrew Stormont about 10 years ago

You can avoid the librt dependency by defining nanosleep to __nanosleep.

Actions #2

Updated by Milan Jurik about 10 years ago

Isn't this GCC upstream bug?

Actions #3

Updated by Ken Mays almost 9 years ago

  • Status changed from New to Closed

Workaround provided. gcc update to 4.6.3 as well.

Actions

Also available in: Atom PDF