Do you find it strange that pthread_setspecific needs const void pointer but pthread_getspecific returns non-const void pointer?
void *pthread_getspecific(pthread_key_t key);
int pthread_setspecific(pthread_key_t key, const void *value);
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Meh, just another const-unsafe C interface. In truth, though, it’s quite impossible to create a
const-safe version of this. If both functions are consistent, then either people who want to store pointers-to-constmust cast awayconstwhen storing the pointer, or people who want to store pointers-to-non-constmust cast awayconstwhen retrieving the pointer.The way it is, it’s not safe, but at least it doesn’t force you to clutter the code with casts.