mardi 14 avril 2020

how to printf() std::this_thread::get_id() in C++?

I've tried to cast to void* and use %p. I've also tried intptr_t with a format of %lx. Both times I get the "Invalid Cast" error.

I'm using -Wall -Werror which checks that the arguments of the printf() match the function's format string. So I can't merely count on get_id() leaving a 4- or 8-byte value on the stack and simply printing that value as hex.

I'm using gcc version 9.2.1 20190827 (Red Hat 9.2.1-1) (GCC)

The OS is Fedora release 31 (Thirty One) . The CPU is 64-bit Intel x86.

Aucun commentaire:

Enregistrer un commentaire