这对我来说非常令人费解,因为代码在Debian 5系统上编译时没有错误,但在FreeBSD 7上,我在第98行遇到语法错误。
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检查更少,我看到的只是空格和换行符。
答案 0 :(得分:1)
在这些类型的神秘错误中,最好的办法是自己运行预处理器并查看结果。有时候标题中的标记是#define
d,而且几乎不可能知道发生了什么。
要执行此操作,请找到此.c文件的编译行并将其运行为:
cpp <all -I switches from the compilation line> <all -D switches> yourfile.c outfile.tmp
尝试在outfile.tmp
中找到相关的行 - 它可能看起来有点乱,但是搜索原始文件名和亚麻布 - 它应该不会太难。当你找到那条线时,希望找到实际问题不是太难。
答案 1 :(得分:1)
您/原作者必须包含文件,其中包含编译成功时定义time_t
的标题。但是,您需要正确找到该文件,以了解问题的正确解决方案。
你不能假设linux不要求你包含那些破坏所有编程基础的文件:)。
答案 2 :(得分:0)
用户Praveen很好地回答了我的问题但是我没有留下未回复的帖子我会提到我发现的内容。
该软件似乎定义了自己的time_t,或者Linux不要求你为time_t数据类型包含time.h。
无论哪种方式,我都可以通过简单地在FreeBSD上包含time.h来继续我的移植。