TarsCloud / TarsCpp

C++ language framework rpc source code implementation
BSD 3-Clause "New" or "Revised" License
523 stars 254 forks source link

Include `<chrono>` for `system_clock` #315

Closed StephanTLavavej closed 1 week ago

StephanTLavavej commented 1 week ago

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 https://github.com/microsoft/STL/pull/5105, which revealed a conformance issue in TarsCpp.

Compiler error with this STL change:

C:\gitP\TarsCloud\TarsCpp\util\include\util\tc_logger.h(1564,32): error C2039: 'system_clock': is not a member of 'std::chrono'

Affected code: https://github.com/TarsCloud/TarsCpp/blob/117bde35693fc244c0cced61a2da9b5b7dc5a289/util/include/util/tc_logger.h#L1564

This was assuming that including <thread> makes the chrono::system_clock type available, which is not guaranteed by the Standard. You must explicitly include <chrono>.