问题
I used -pthread for gcc compiler, but still can not find this API. any suggestion?
回答1:
It's a non-standard GNU extension, as the manual and the suffix _np will tell you, so include the header like this:
#define _GNU_SOURCE
#include <pthread.h>
回答2:
Your command must looks like this way...
$ > gcc -lpthread YourProg.c
if it is .cpp
then >>
$ > g++ -lpthread YourProg.cpp
回答3:
because it is not a posix function,so maybe you can use it in somewhere,and you can not use it in some other where. So carefully use it.
来源:https://stackoverflow.com/questions/7269839/can-not-find-pthread-setaffinity-np