Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/63.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 这是pthread C+的不可移植错误吗+;程序_C++_C_Linux_Pthreads - Fatal编程技术网

C++ 这是pthread C+的不可移植错误吗+;程序

C++ 这是pthread C+的不可移植错误吗+;程序,c++,c,linux,pthreads,C++,C,Linux,Pthreads,我正在编写一个pthC++程序。 我得到一个错误: “pthread_getunique_np”未在此范围内声明 pthread_getunique_np或带有“*np”的其他线程不可移植 我无法从网上的帖子中找到解决方案 我知道这意味着它不是POSIX标准 如何避开这个问题?我需要包含一些头文件或其他替代文件 谢谢后缀的意思是“不可携带”。换句话说,它不是POSIX标准的一部分,因此不能保证在POSIX系统上可用。后缀的意思是“不可移植”。换句话说,它不是POSIX标准的一部分,因此不能保证在

我正在编写一个pthC++程序。 我得到一个错误: “pthread_getunique_np”未在此范围内声明

pthread_getunique_np或带有“*np”的其他线程不可移植

我无法从网上的帖子中找到解决方案

我知道这意味着它不是POSIX标准

如何避开这个问题?我需要包含一些头文件或其他替代文件


谢谢

后缀的意思是“不可携带”。换句话说,它不是POSIX标准的一部分,因此不能保证在POSIX系统上可用。

后缀的意思是“不可移植”。换句话说,它不是POSIX标准的一部分,因此不能保证在POSIX系统上可用。

只需使用
pthread\u t
作为唯一标识符即可。无论如何,我很可能与
pthread\u getunique\u np的返回值相同。

只要使用
pthread\u t
作为唯一标识符即可。无论如何,我很可能与
pthread\u getunique\u np的返回值相同。

正如Martin所说,在许多系统上,您可以使用线程的
pthread\u t
作为唯一标识符。您可以使用POSIX中的
pthread\u self(3)
来检索它。您可以使用函数
pthread_equal(3)
测试两个
pthread_t
s的等效性

pthread_t threadID = pthread_self();
if (pthread_equal(threadID, someOtherID) != 0)
    /* Branch based on being the same thread */
else
    /* Branch based on being different threads */
据我所知,
pthread\u getunique\u np()
返回一个唯一的整数ID,这与使用
pthread\u t
作为标识符不同。在许多系统上,从
pthread\u self(3)
和f
pthread\u getunique\u np()
返回的值是相同的。实际上,您需要
pthread\u t
来获得唯一的整数

无论采用哪种方式,都需要使用
pthread\u self(3)
返回调用它的线程的ID,因此我相信您应该能够按照自己的方式使用此可移植函数


(关于
pthread\u getunique\u np()
from)的信息)

正如Martin所说,在许多系统上,您可以使用线程的
pthread\u t
作为唯一标识符。您可以使用POSIX中的
pthread\u self(3)
来检索它。您可以使用函数
pthread_equal(3)
测试两个
pthread_t
s的等效性

pthread_t threadID = pthread_self();
if (pthread_equal(threadID, someOtherID) != 0)
    /* Branch based on being the same thread */
else
    /* Branch based on being different threads */
据我所知,
pthread\u getunique\u np()
返回一个唯一的整数ID,这与使用
pthread\u t
作为标识符不同。在许多系统上,从
pthread\u self(3)
和f
pthread\u getunique\u np()
返回的值是相同的。实际上,您需要
pthread\u t
来获得唯一的整数

无论采用哪种方式,都需要使用
pthread\u self(3)
返回调用它的线程的ID,因此我相信您应该能够按照自己的方式使用此可移植函数


(关于
pthread\u getunique\u np()
from)的信息)

使用其他函数。。。?看看你更广泛的目标,找到一个不同的解决方案。使用不同的功能。。。?看看你更广泛的目标,找到一个不同的解决方案。谢谢,我知道。我需要知道如何避开它。谢谢,我知道。我需要知道如何避开它。