繁体   English   中英

如何解决“函数的隐式声明”

[英]How to fix “ implicit declaration of function”

我正在使用C的GUI库进行学校作业,但是头文件存在问题(我认为)。 我在“ draw.c”文件中有一个函数“ rectangle_coordinates”,带有足够的“ draw.h”头文件,在文件“ widget_frame.c”中,我在包含“ draw.h”头之后调用了此函数文件。 但是我仍然得到警告:

./src/ei_widget_frame.c:40:5: warning: implicit declaration of function 'rectangle_coordinates' [-Wimplicit-function-declaration]
     rectangle_coordinates(&frame_to_draw, &xmin, &xmax, &ymin, &ymax);

您有解决我问题的想法吗?

至少,应验证和纠正以下所有内容(如果需要)。

  1. 函数名称在所有位置都必须相同(检查拼写错误)。
  2. 返回类型在所有地方都必须相同。
  3. 所有地方的参数列表必须相同。

draw.h您应该具有以下内容:

extern /type/ rectangle_coordinates(&frame_to_draw, &xmin, &xmax, &ymin, &ymax);

哪里:

  • / type /是函数的返回类型。
  • 参数列表需要正确编写(我只是从提供的警告消息中进行了复制/粘贴)。

draw.cei_widget_frame.c您都应具有:

#include "draw.h"

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM