隐式声明 static 的问题(编译自定义 mupdf 库)
我正在使用 mupdf 库中某些函数的自定义版本来编译 mupdf。有两个函数似乎互相调用,因此当我创建它们的 _custom
版本时,会在编译时发出错误。
pc@pc:~/sviluppo/mupdf-0.9$ make
CC build/debug/obj_print.o
fitz/obj_print.c: In function ‘fmt_array_custom’:
fitz/obj_print.c:191:4: warning: implicit declaration of function ‘fmt_obj_custom’
fitz/obj_print.c: At top level:
fitz/obj_print.c:304:13: warning: conflicting types for ‘fmt_obj_custom’
fitz/obj_print.c:304:13: error: static declaration of ‘fmt_obj_custom’ follows non-static declaration
fitz/obj_print.c:191:4: note: previous implicit declaration of ‘fmt_obj_custom’ was here
make: *** [build/debug/obj_print.o] Errore 1
怎么了?函数的默认版本已经以相同的方式相互调用。
I am compiling mupdf with a custom version of some functions in mupdf library. There are two functions that seem to call each other so when I create the _custom
version of them an error is issued at compile time.
pc@pc:~/sviluppo/mupdf-0.9$ make
CC build/debug/obj_print.o
fitz/obj_print.c: In function ‘fmt_array_custom’:
fitz/obj_print.c:191:4: warning: implicit declaration of function ‘fmt_obj_custom’
fitz/obj_print.c: At top level:
fitz/obj_print.c:304:13: warning: conflicting types for ‘fmt_obj_custom’
fitz/obj_print.c:304:13: error: static declaration of ‘fmt_obj_custom’ follows non-static declaration
fitz/obj_print.c:191:4: note: previous implicit declaration of ‘fmt_obj_custom’ was here
make: *** [build/debug/obj_print.o] Errore 1
What's wrong? the default version of the functions already call each other the same way.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在第 191 行,函数
fmt_array_custom
在没有事先声明的情况下被调用。因此编译器隐式地假定一个声明(非静态
)。稍后在第 304 行,它看到实际的函数声明/定义是
static
。这是一个冲突。为了解决这个问题,您可以在第 191 行之前添加一个声明。只需从第 304 行复制函数原型(不带主体)即可。
In line 191, the function
fmt_array_custom
is called without prior declaration. So the compiler implicitly assumes a declaration (non-static
).Later in line 304, it sees the actual function declaration/definition which is
static
. This is a conflict.For fixing this you can add a declaration before line 191. Just copy the function proto-type (without the body) from line 304.