小编Jay*_*lam的帖子

错误:'CLOCK_MONOTONIC' 未声明(首次在此函数中使用)

我尝试在 opencv 3.0 中构建基于像素强度比较的对象检测 (pico)代码,在构建时出现类似 error: 'CLOCK_MONOTONIC' undeclared (first use in this function) 的错误。谁能告诉如何克服这些问题?代码如下以及我得到的错误

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;
}
Run Code Online (Sandbox Code Playgroud)

我得到的错误是

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 …
Run Code Online (Sandbox Code Playgroud)

c c++ opencv

4
推荐指数
1
解决办法
8606
查看次数

标签 统计

c ×1

c++ ×1

opencv ×1