I am coding for a pthread C++ program.
I got error:
“pthread_getunique_np” was not declared in this scope
The pthread_getunique_np or others with “*np” are not portable.
I cannot find solutions from posts online .
I know _np means it is not a POSIX standard.
How to get around this ? I need to include some header files or other substitutes ?
thanks
Like Martin said, on many systems, you can just used the
pthread_tof the thread as a unique identifier. You can retrieve this withpthread_self(3), which is POSIX. You can use the functionpthread_equal(3)to test twopthread_ts for equivalence.As far as I can tell,
pthread_getunique_np()returns a unique integer ID, which is different than using apthread_tas an identifier. On many systems, the values returned from bothpthread_self(3)andfpthread_getunique_np()are the same. In fact, you need thepthread_tto obtain the unique integer.Either way,
pthread_self(3)is required to return the ID of the thread from which it is called, so I believe you should be able to use this portable function the way you want.(Information about
pthread_getunique_np()from IBM)