简体   繁体   中英

How to fix “ implicit declaration of function”

I'm working on a GUI library in C for a school work, but I've got a problem with header files (I think). I have a function "rectangle_coordinates" in a "draw.c" file, with the adequate "draw.h" header file, and in a file "widget_frame.c" I call this function, after including the "draw.h" header file. But I still got a warning :

./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);

Do you have an idea that can fix my problem ?

At a minimum, all things below should be verified and corrected (if needed).

  1. The function name must be the same in all places (check for typo's).
  2. The return type must be the same in all places.
  3. The parameters list must be the same in all places.

In draw.h you should have something like:

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

where:

  • /type/ is the return type of the function.
  • the parameters list needs to be written correctly (I just made copy / paste from the warning message provided).

In both draw.c and ei_widget_frame.c you should have:

#include "draw.h"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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