安裝 libevent 出錯: event.c error: 'CLOCK_MONOTONIC' undeclared

安裝 libevent 出錯: event.c error: 'CLOCK_MONOTONIC' undeclared


在編譯 libevent-1.2 源碼時, make 出錯:memcached

event.c:157:20: error: 'CLOCK_MONOTONIC' undeclared (first use in this function)
  if (clock_gettime(CLOCK_MONOTONIC, &ts) == -1)
                    ^
  • 出錯緣由是: 在 event.c 文件中 CLOCK_MONOTONIC 沒有定義.
  • 解決辦法 : 在網上搜了下, 是缺乏頭文件了, CLOCK_MONOTONIC 定義在 time.h 頭文件中. 因此能夠直接修改源碼:
    在 event.c 中引用頭文件: #include <time.h> :

/* 直接在event.c文件最上面include time.h 就能夠了. /
#include <time.h>
/
如下是源碼, 不用管! */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endifthis


[reference]

CADN ACM_devil 安裝memcached (他沒說要 include 什麼...).net

相關文章
相關標籤/搜索