-
Notifications
You must be signed in to change notification settings - Fork 685
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Waybar fails to compile with clang/libcxx because of date/tz.h #799
Comments
I suspect that this is a conflict with C++20. This library isn't compatible with C++20 because it was adopted into C++20. The ambiguity is likely between the streaming operator for sys_time in date, and the same operator in std::chrono. |
I'm seeing this as well on mac os. It happens after I updated clang from 16 to 17. Interestingly, it does not seem to happen on linux using the same compiler version (17). |
Additionally, here including |
My latest info is that chrono C++20 is supported on MSVC, gcc-14 (which hasn't shipped yet), and not on llvm. |
Right. Do you have any advice on how to work around this issue on clang 17 then? I'd like to still use this header for time zone arithmetic on my project... I guess I don't really understand what changed from clang 16 to 17 that causes this error. |
@@ -33,10 +37,28 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)
+#if _LIBCPP_STD_VER >= 20
namespace chrono {
+template <class _CharT, class _Traits, class _Duration>
+_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os, const sys_time<_Duration> __tp) {
+ return __os << std::format(__os.getloc(), _LIBCPP_STATICALLY_WIDEN(_CharT, "{:L%F %T}"), __tp);
+}
+
+template <class _CharT, class _Traits, class _Duration>
+_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os, const file_time<_Duration> __tp) {
+ return __os << std::format(__os.getloc(), _LIBCPP_STATICALLY_WIDEN(_CharT, "{:L%F %T}"), __tp);
+}
+
+template <class _CharT, class _Traits, class _Duration>
+_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os, const local_time<_Duration> __tp) {
+ return __os << sys_time<_Duration>{__tp.time_since_epoch()};
+}
+
// Depending on the type the return is a const _CharT* or a basic_string<_CharT>
template <class _CharT, class _Period>
_LIBCPP_HIDE_FROM_ABI auto __units_suffix() { libc++ 17.0.0 introduced an output operator for Unfortunately I don't have a good idea how to work around it :-/ |
Thanks. I tried to specialize the template for that function for the concrete types it is complaining about, hoping that it would desambiguate, but with no luck. I still don't understand how using proper namespaces cannot prevent this from happening. How about introducing some macro that would disable these redundant definitions of operator<<? Could even be set as a function of being compiled with clang 17? |
A error in the header seems to be causing waybar to fail to compile. dev-libs/date (this library) compiles fine though 🤔
uname -a:
Linux gigatop 6.5.0-rc2-gentuwu-kernel-g84f54d4966f4 #4 SMP PREEMPT_DYNAMIC Sat Sep 9 20:57:48 PDT 2023 x86_64 Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz GenuineIntel GNU/Linux
The text was updated successfully, but these errors were encountered: