Explicitly include <chrono> - #13537
Merged
Merged
Conversation
Contributor
|
Can one of the admins verify this patch? |
Nir-Az
self-requested a review
November 24, 2024 06:57
Collaborator
|
@StephanTLavavej Thanks for the fix. |
Merged
7 tasks
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I work on Microsoft Visual C++, 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.
I just merged microsoft/STL#5105, which revealed a conformance issue in librealsense.
Compiler error with this STL change:
Affected code:
https://github.com/IntelRealSense/librealsense/blob/a75366ff9e40e765993b15ad6f18b45200616a73/src/backend.cpp#L56
src/backend.cppincludesplatform/uvc-device.hwhich includes<thread>:https://github.com/IntelRealSense/librealsense/blob/a75366ff9e40e765993b15ad6f18b45200616a73/src/backend.cpp#L19
https://github.com/IntelRealSense/librealsense/blob/a75366ff9e40e765993b15ad6f18b45200616a73/src/platform/uvc-device.h#L18
This was assuming that including
<thread>makes thechrono::system_clocktype available, which is not guaranteed by the Standard. You must explicitly include<chrono>.platform/uvc-device.hitself useschrono::milliseconds:https://github.com/IntelRealSense/librealsense/blob/a75366ff9e40e765993b15ad6f18b45200616a73/src/platform/uvc-device.h#L194
While MSVC's STL still has
<thread>dragging inchrono::milliseconds, this is also not guaranteed by the Standard. Therefore, the proper change is to include<chrono>inplatform/uvc-device.h.