我很难理解thrd_join的用法。其声明是这样的: int thrd_join(thrd_t thr, int *res);
的部分写着: 如果资源不是一个空指针,该线程的结果代码放到位置指向资源 所以我认为变量res包含要加入的线程的返回码。那么使用thrd_join()的返回值是多少?这是否表示加入成功,我可以认真对待res的内容? 我有这个权利吗?
我已经使用了一个非常简单的代码: int main(void)
{
size_t variable;
/*prompt*/
printf("enter the value of the variable: ");
scanf("%zd", &variable);
printf("you entered %zd value of the varia
我认为描述我的问题的简单方法是在代码中演示它,所以这里是C中一个人为的例子,以突出我有兴趣回答的问题: // Just some complex user defined type
typedef struct {
...
} state_t;
typedef struct {
state_t states[16];
} state_list_t;
static
下面的代码段是从C11 standard §6.5.2.3一个例子: struct t1 { int m; };
struct t2 { int m; };
int f(struct t1 *p1, struct t2 *p2)
{
if (p1->m < 0)
p2->m = -p2->m;
return p1->m;
}
int g()
{