Searched, but don’t come across a satisfying answer.
I know there’s no a portable way to print a pthread_t.
How do you do it in your app?
Update:
Actually I don’t need pthread_t, but some small numeric id, identifying in debug message different threads.
On my system (64 bit RHEL 5.3) it’s defined as unsigned long int, so it’s big number and just printing it eats a valuable place in debug line. How does gdb assign short tids?
This will print out a hexadecimal representation of a
pthread_t, no matter what that actually is:To just print a small id for a each
pthread_tsomething like this could be used (this time using iostreams):Depending on the platform and the actual representation of
pthread_tit might here be necessary to define anoperator<forpthread_t, becausestd::mapneeds an ordering on the elements: