Pthread et gcc compiler question sur OS X

J'ai un script qui compile bien sous Linux (Ubuntu 11.04), mais pas sur OS X (Lion).

gcc -pthread -o hw1 hw1.c 
hw1.c:22: error: expected ‘=’, ‘,’, ‘;’, asm or __attribute__ before barr
hw1.c: In function __syncthreads’:
hw1.c:53: error: barr undeclared (first use in this function)
hw1.c:53: error: (Each undeclared identifier is reported only once
hw1.c:53: error: for each function it appears in.)
hw1.c:54: error: PTHREAD_BARRIER_SERIAL_THREAD undeclared (first use in this function)
hw1.c: In function parallel_psum’:
hw1.c:94: error: barr undeclared (first use in this function)
hw1.c:107: warning: assignment from incompatible pointer type

Voici les 22 premières lignes de code:

#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <sys/time.h>
#include <pthread.h>
#include <assert.h>

/* create thread argument struct for thr_func() */
typedef struct _thread_data_t {
    int tid;
    int* ints;
    int* sums;
    int num_ints;
    int* temp;
} thread_data_t;

const int MIN_RAND_INT = 1;
const int MAX_RAND_INT = 65000;

//pthreads barrier variable
pthread_barrier_t barr;

Des idées pourquoi ce qui se passe?

Semble que pthread_barrier_t n'est pas défini.
C'est un type défini par la bibliothèque pthread de ce que je comprends
OSX ne peut pas avoir pthred_barrier_t. Un indice sur ce qui a été mentionné dans this question
Eh bien, qui précise que. Linux pour le gagner 🙂 merci
Oui, OS X semble un peu à une POSIX figé autour de 2001. Aider les gens à écrire moderne conforme à la norme code ne semble pas être leur objectif premier.

OriginalL'auteur Dolan Antenucci | 2012-01-19