Skip to content

Conversation

@halflumi
Copy link
Contributor

@halflumi halflumi commented Mar 1, 2022

Attempting to compile the example code in C++/WinRT FAQ with Clang (LLVM 14) and C++/WinRT 2.0.220224.4 results in the following compilation error:

winrt/base.h(8272,77): error: no viable conversion from 'time_point<[...], duration<[...], ratio<[...], __static_lcm<ratio<1, 10000000>::den, ratio<1, 1>::den>::value aka 10000000>>>' to 'const time_point<[...], duration<[...], ratio<[...], 1000000>>>'
            return static_cast<time_t>(std::chrono::system_clock::to_time_t(to_sys(time)));
                                                                            ^~~~~~~~~~~~

This originates from the fact that system_clock uses microseconds in libc++ instead of the 100 nanoseconds in STL of MSVC. A time_point_cast solves the problem. With this change, the example code is able to be compiled in Clang with no other compilation errors.

@kennykerr kennykerr requested a review from DefaultRyan March 2, 2022 00:08
@kennykerr
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Collaborator

@kennykerr kennykerr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@kennykerr kennykerr merged commit 8484e43 into microsoft:master Mar 4, 2022
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.

2 participants