【问题标题】:How to tell netbeans information on pthread_barrier_t如何在 pthread_barrier_t 上告诉 netbeans 信息
【发布时间】:2012-02-21 00:03:06
【问题描述】:

我似乎无法让 netbeans 识别 pthread_barrier_t 类型。我可以输入#include<pthread.h> 好的,但是 pthread_barrier_t 没有运气。

以下是构建和错误:

g++ -lpthread -c -g -MMD -MP -MF build/Debug/GNU-MacOSX/main.o.d -o 构建/调试/GNU-MacOSX/main.o main.cpp main.cpp:32:错误: 'pthread_barrier_t' 没有命名类型

我使用的是 Netbeans 7.1,我使用的是 Mac OSX 10.7.2 我可以创建线程而没有任何编译问题。

bool isNotInSteadyState()
{
    int rc = 0;
    threadData threadDataArray[NUM_THREADS];
    int dataArrayCount = 0;
    if (NUM_THREADS < ((PLATE_SIZE - 2) * (PLATE_SIZE - 2)))
    {
        for (int i = 1; i < PLATE_SIZE - 1; i += sqrt(NUM_THREADS))
        {
           for (int j = 1; j < PLATE_SIZE - 1; j += sqrt(NUM_THREADS))
           {
                threadDataArray[dataArrayCount].endY = i + sqrt(NUM_THREADS) - 1;
                threadDataArray[dataArrayCount].x = i;
                threadDataArray[dataArrayCount].endY = j + sqrt(NUM_THREADS) - 1;
                threadDataArray[dataArrayCount++].y = j;
                pthread_t* thread;

                int pthread_create(thread, NULL,isNotInSteadyStateCheckRunInParallel, &threadDataArray[dataArrayCount]);
                if (dataArrayCount >= NUM_THREADS)
                {
                    //pthread_barrier_init(pthread_barrier_t * barrier,
              //const pthread_barrierattr_t *restrict attr, NUM+THREADS);
                }
                if (rc != 0)
                {
                        fprintf(stderr, "Steady State check failed!\n");
                }
          }
       }
    }    

}

想法?

谢谢,

【问题讨论】:

  • 我不使用 netbeans,所以我真的不知道你在问什么,但 pthread_barrier_t 不是命令,它是一种类型。
  • 我改变了术语,所以它更正确
  • 您的意思是您可以在 Netbeans 中获得某种“智能感知”,或者如果您尝试使用 pthread_barrier_t,您会遇到编译器/构建错误?如果是后者,请详细说明错误、工具版本和使用的平台。
  • 您可以在 Netbeans 中获得“智能感知”。当我尝试使用它时,我也遇到了构建错误
  • 哦。此链接可能是问题的一部分。 stackoverflow.com/questions/8920803/… 而这个:stackoverflow.com/questions/3640853/… 你可能是 SOL。

标签: c++ macos netbeans pthreads


【解决方案1】:

根据 opengroup.org 上的info about pthread_barriers,障碍在 POSIX 1003.1 2004 版的 optional 部分中定义;选项的名称是“(ADVANCED REALTIME THREADS)”,有时更准确地称为“BAR,障碍(实时)”。

列出所有 POSIX 选项here

2.1.3 POSIX Conformance
POSIX System Interfaces

系统可能支持由以下符号常量表示的一个或多个选项(请参阅选项):

_POSIX_BARRIERS

所以,只有当 _POSIX_BARRIERS 宏定义为正数时,才可以使用 pthread_barrier_t 或 pthrad_barrier_wait。

Mac OS X 与 POSIX 兼容,但我找不到已实现选项的完整列表。我知道 Solaris 也有 pthread_barrier 的问题。 There is a post 在 2006 年的苹果 mainling 列表中。它说 Mac OS X 没有障碍

【讨论】:

  • 很高兴知道。对此似乎有相当多的困惑。
猜你喜欢
  • 1970-01-01
  • 2017-01-11
  • 2011-04-22
  • 2018-11-04
  • 1970-01-01
  • 2011-10-31
  • 1970-01-01
  • 1970-01-01
  • 2013-09-27
相关资源
最近更新 更多