gpt4 book ai didi

netbeans (cygwin) 中的 C pthread_barriers

转载 作者:太空宇宙 更新时间:2023-11-03 23:25:50 25 4
gpt4 key购买 nike

我想在 netbeans 中编写一些学校的 C 任务。他们给了我们必须使用 pthread_barrier 的任务。所以我用 gcc、g++、gdb 和 make 下载了 netbeans 和 cygwin。在 pthreads.h 中没有任何 pthread_barrier_t 等。在 this question 中我发现“障碍在 POSIX 1003.1 2004 版的可选部分中定义”。问题是如何通过 cygwin 在 netbeans 中使用屏障?

部分代码:

//#define _POSIX_BARRIERS 1 
//I don't get it what they mean
//"only if the _POSIX_BARRIERS macro is defined as positive number,
//you can use pthread_barrier_t"

#define _XOPEN_SOURCE 600

#include <stdlib.h>
#include <stdbool.h>
#include <stdio.h>
#include <unistd.h>
#include <pthread.h>
#include <semaphore.h>

// declaration of the barrier
pthread_barrier_t a_barrier; // err: Unable to resolve identifier pthread_barrier_t.

最佳答案

Cygwin 当前不支持 pthread_barrier_*,因此您将无法编译或运行需要在 Cygwin 上使用的代码。

关于netbeans (cygwin) 中的 C pthread_barriers,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27650215/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com