错误:'CLOCK_MONOTONIC'未声明(首次使用此功能)

时间:2015-04-16 06:29:59

标签: c++ c opencv

我尝试在opencv 3.0中构建基于像素强度比较的对象检测(微微)代码,同时构建我的错误如错误:' CLOCK_MONOTONIC'未申报(首次使用此功能)。谁能说出如何克服这些问题?代码如下以及我得到的错误

float getticks()
{
    struct timespec ts;

    if(clock_gettime(CLOCK_MONOTONIC, &ts) < 0)
    {
        printf("clock_gettime error\n");

        return -1.0f;
    }

    return ts.tv_sec + 1e-9f*ts.tv_nsec;
}

和我得到的错误

picolrn.c:94:18: error: storage size of 'ts' isn't known
  struct timespec ts;
                  ^
picolrn.c:96:19: error: 'CLOCK_MONOTONIC' undeclared (first use in this function)
  if(clock_gettime(CLOCK_MONOTONIC, &ts) < 0)
                   ^
picolrn.c:96:19: note: each undeclared identifier is reported only once for each function it appears in
make.exe[2]: *** [build/Debug/MinGW_1-Windows/picolrn.o] Error 1

1 个答案:

答案 0 :(得分:4)

编译时添加命令行开关:$("myButtonForShowDialog").button().on("click", function() { myFormDialog.dialog("open"); });

没有它,time.h标头将不会定义它。