文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>使用读写锁pthread_rwlock_t未定义的问题

使用读写锁pthread_rwlock_t未定义的问题

时间:2006-09-15  来源:fytzzh

今天在程序里使用读写锁包括以下函数:

#include <pthread.h>
int pthread_rwlock_rdlock(pthread_rwlock_t *rwptr);
int pthread_rwlock_wrlock(pthread_rwlock_t *rwptr);
int pthread_rwlock_unlock(pthread_rwlock_t *rwptr);


int pthread_rwlock_tryrdlock(pthread_rwlock_t *rwptr);
int pthread_rwlock_trywrlock(pthread_rwlock_t *rwptr);


int pthread_rwlock_init(pthread_rwlock_t *rwptr,
                     const pthread_rwlockattr_t *attr);
int pthread_rwlock_destroy(pthread_rwlock_t *rwptr);

int pthread_rwlockattr_init(pthread_rwlockattr_t *attr)
int pthread_rwlockattr_destroy(pthread_rwlockattr_t * attr);

int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t * attr, int *valptr);

int pthread_rwlockattr_setpshared(pthread_rwlockattr_t* attr, int value);
                  都返回:成功 0,出错为正的Exxxx值

测试程序如下:

#include <pthread.h>

pthread_rwlock_t lock = PTHREAD_RWLOCK_INITIALIZER;

int main()

{

       return 0;

}

 

$ gcc –o lock lock.c
$ lock.c:2: parse error before `lock'

$ lock.c:2: `PTHREAD_RWLOCK_INITIALIZER' undeclared here (not in a function)

$ lock.c:2: warning: data definition has no type or storage class

 

最后查文档解决方是:
在程序开头加入:
#define _XOPEN_SOURCE 500

相关阅读 更多 +
排行榜 更多 +
拼优汇

拼优汇

购物比价 下载
4Read小说

4Read小说

浏览阅读 下载
摩托GP特技

摩托GP特技

体育竞技 下载