Skip to contentSkip to conversation

bindings: cxx: fix building gpiod::timestamp with clang

PATCH New Bartosz Golaszewski 1 participant 1 message Feb 10, 2023 GPIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bindings: cxx: fix building gpiod::timestamp with clang

From: Bartosz Golaszewski <[email protected]>

Clang's system_clock implementation uses microseconds resolution by default and we fail to construct a time_point out of chrono::nanoseconds as the library prohibits us from accidentally losing information when casting the latter to the former. Use nanoseconds explicitly as the resolution of the realtime timestamp.

---
 bindings/cxx/gpiodcxx/timestamp.hpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
bindings/cxx/gpiodcxx/timestamp.hpp +2 -1
index 2eaadd2..5efeb4c 100644
@@ -38,7 +38,8 @@ public:
 	/**
 	 * @brief Real-time time_point.
 	 */
-	using time_point_realtime = ::std::chrono::time_point<::std::chrono::system_clock>;
+	using time_point_realtime = ::std::chrono::time_point<::std::chrono::system_clock,
+							      ::std::chrono::nanoseconds>;
 
 	/**
 	 * @brief Constructor with implicit  conversion from `uint64_t`.
Signature · 1 line
2.37.2