Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@NEIL-smtg
Copy link

@NEIL-smtg NEIL-smtg commented Nov 26, 2024

I work on Microsoft Visual C++ testing, where we regularly build popular open-source projects, including yours, with development builds of our compiler and libraries to detect and prevent shipping regressions that would affect you. This also allows us to provide advance notice of breaking changes, which is the case here.

Recently this commit microsoft/STL#5105 is revealing an issue in nysnc.

Compiler error with this STL change:

./external/nsync//platform/c++11\platform.h(67): error C2039: 'system_clock': is not a member of 'std::chrono'
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.42.34433\include\__msvc_chrono.hpp(286): note: see declaration of 'std::chrono'
./external/nsync//platform/c++11\platform.h(67): error C3083: 'system_clock': the symbol to the left of a '::' must be a type
./external/nsync//platform/c++11\platform.h(67): error C2133: 'epoch': unknown size
./external/nsync//platform/c++11\platform.h(67): error C2512: 'std::chrono::time_point': no appropriate default constructor available
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.42.34433\include\__msvc_chrono.hpp(200): note: see declaration of 'std::chrono::time_point'
./external/nsync//platform/c++11\platform.h(69): error C2676: binary '+': 'std::chrono::time_point' does not define this operator or a conversion to a type acceptable to the predefined operator

Affected code:

std::chrono::system_clock::time_point epoch;
result = (*cv)->wait_until (mu_mu,
epoch + std::chrono::nanoseconds (
abstimeout->tv_nsec +
1000 * 1000 * 1000 * (int64_t) abstimeout->tv_sec));

This was assuming that including makes the chrono::system_clock type available, which is not guaranteed by the Standard. You need to explicitly include the chrono header in this file, and the error will be resolved.

@google-cla
Copy link

google-cla bot commented Nov 26, 2024

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@StephanTLavavej
Copy link

After signing the CLA, the addition of <chrono> should be grouped with <mutex> and <condition_variable>, to avoid interfering with the comment about C compatibility headers.

@m3bm3b
Copy link
Collaborator

m3bm3b commented Apr 9, 2025

Sorry for the delay.

The change looks ok, but the new include directive is right under a comment that doesn't apply to it.
Could you move it to just after the line that includes "condition_variable"?
That way, the C++-specific include files are together.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants