Can not find `pthread_setaffinity_np'?

血红的双手。 提交于 2019-12-24 09:58:12

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!