Does main()'s pthread ID default to 0?

Pthread_t should be treated as an opaque type; there is a function pthread_equal() that you should use to compare thread pthread_t objects. Casting to unsigned int is definitely undefined behavior, as is comparing to an int with.

Pthread_t should be treated as an opaque type; there is a function pthread_equal() that you should use to compare thread pthread_t objects. Casting to unsigned int is definitely undefined behavior, as is comparing to an int with ==.

...GOOD point. Glad I'm checking. – Ziv Mar 23 at 12:26.

In addition, the zero you've got was printed only because you actually didn't link with libpthread at all. Consider: #include #include int main(){ printf("Main ID is %lx\n", (unsigned long)pthread_self()); } $ g++ -g t. C && .

/a. Out Main ID is 0 $ g++ -g t. C -pthread && .

/a. Out Main ID is 7fd1a288d720 I don't buy this because on my MacBook, I get $ g++ -g t. C && .

/a. Out Main ID is a092e720.

1 This is implementation-specific. Surely there are some (IMO broken) implementations where the real pthread_self is in libpthread and stub pthread functions exist in the main libc, so I'm not at all surprised if this happens. On the other hand it's definitely not something you can rely on.

– R.. May 21 at 15:04.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions