这对我来说非常困惑,因为代码在Debian 5系统上编译时没有错误,但在FreeBSD 7上编译时出现语法错误,例如第98行。将C代码从Linux移植到FreeBSD的语法错误
int ipmi_fru_get_board_info_mfg_time(ipmi_fru_t *fru, time_t *time);
原来在* fru和time_t之间有一个换行符。不知道什么可能导致这些编译器错误,但提到换行符很重要。
或者第298行的这一个完全没有改变其格式。
int ipmi_fru_get(ipmi_fru_t *fru,
int index,
char **name,
int *num,
enum ipmi_fru_data_type_e *dtype,
int *intval,
time_t *time,
char **data,
unsigned int *data_len);
这些是输出到终端的未改变的错误。
In file included from out_fru.c:37:
../include/OpenIPMI/ipmi_fru.h:98: error: expected declaration specifiers or '...' before 'time_t'
../include/OpenIPMI/ipmi_fru.h:298: error: expected declaration specifiers or '...' before 'time_t'
../include/OpenIPMI/ipmi_fru.h:474: error: expected declaration specifiers or '...' before 'time_t'
../include/OpenIPMI/ipmi_fru.h:559: error: expected declaration specifiers or '...' before 'time_t'
../include/OpenIPMI/ipmi_fru.h:627: error: expected declaration specifiers or '...' before 'time_t'
后续的错误似乎是相关的,因为它们影响在ipmi_fru.h头文件的上述行中声明的函数。
out_fru.c: In function 'ipmi_cmdlang_dump_fru_info':
out_fru.c:87: warning: passing argument 7 of 'ipmi_fru_get' from incompatible pointer type
out_fru.c:87: warning: passing argument 8 of 'ipmi_fru_get' from incompatible pointer type
out_fru.c:87: error: too many arguments to function 'ipmi_fru_get'
什么可能导致这些奇怪的平台特定的语法错误?我的第一个想法是一些不可打印的字符,但我试过用cat -e include/OpenIPMI/ipmi_fru.h |更少,我看到的只有空格和换行符。
如何为time_t结构包含文件?你有没有检查这个结构是否存在以及结构的定义是什么? – 2010-07-15 09:39:17
你对我的好先生绝对正确,显然你不需要time.h在Linux上包含time.h。新闻给我。 – 2010-07-15 09:57:52