尝试编译CheckMK的livestatus Nagios插件时,在“ make”过程中出现错误:
g++ -DHAVE_CONFIG_H -I. -I.. -I../nagios -fPIC -g -O2 -MT livestatus_so-TableLog.o -MD -MP -MF .deps/livestatus_so-TableLog.Tpo -c -o livestatus_so-TableLog.o `test -f 'TableLog.cc' || echo './'`TableLog.cc
TableLog.cc: In member function ‘void TableLog::updateLogfileIndex()’:
TableLog.cc:250:21: error: expected primary-expression before ‘struct’
TableLog.cc:250:36: error: ‘d_name’ was not declared in this scope
TableLog.cc:250:42: error: ‘offsetof’ was not declared in this scope
make[2]: *** [livestatus_so-TableLog.o] Error 1
TableLog.cc的相关部分:
250 int len = offsetof(struct dirent, d_name)
251 + pathconf(log_archive_path, _PC_NAME_MAX) + 1;
源位于http://www.mathias-kettner.de/download/mk-livestatus-1.1.6p1.tar.gz
有一个有关此问题的邮件列表线程(http://permalink.gmane.org/gmane.network.nagios.checkmk/2560),但仍未得到答复。
最佳答案
TableLog.cc缺少定义了offsetof()宏的“ stddef.h”包含文件。
只需添加
#include <stddef.h>
到TableLog.cc的开头