login
Header Space

 
 

pthread_self

June 18, 2008 - 7:50am
Submitted by jelari on June 18, 2008 - 7:50am.
Linux

Hi i have create a POSIX thread and trying to pring thread id through pthread_self(), when i print that with %d or %ld, i am getting the negative value?.. what is the workaround for this issue?. My linux version is
2.6.22-14-server.

Pthread ids are long

June 18, 2008 - 1:23pm

Pthread ids are long unsigned int, while %d is for signed ints. Try using %u instead or %lu.

pthread_t is an opaque type.

June 18, 2008 - 7:13pm
Paul Brook (not verified)

pthread_t is an opaque type. Expect anything that tries to manipulate it directly (e.g. by passing it as an argument to printf) to break.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
speck-geostationary