I am using Ubuntu virtual box and writing a project in C++. I am unable to put a format specifier for atomic<uint64_t> datatype in C++.
Advertisement
Answer
Use .load()
to get uint64_t
out of the atomic, then print it as a regular uint64_t
using PRIu64
:
#include <atomic> #include <cinttypes> #include <cstdint> #include <cstdio> int main() { std::atomic<std::uint64_t> x = 42; std::printf("x = %" PRIu64 "n", x.load()); }