【发布时间】:2015-02-23 08:35:04
【问题描述】:
我想用 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.
【问题讨论】:
标签: c netbeans cygwin pthreads barrier