2023-02-06 02:22 AM
Hello all,
I have referred the STM32cubeIDE user manual and found the procedure to add the .o file to the project.
I want to call a function from the added .o file.
But I get the following error.
../Core/Src/main.c:130:3: warning: implicit declaration of function 'add2Num' [-Wimplicit-function-declaration]
130 | add2Num(1,2);
How can I solve this issue.
Solved! Go to Solution.
2023-02-06 02:32 AM
> But I get the following error.
No, you get a warning. The compiler doesn't see a declaration of add2Num unless you include a .h file or declared add2Num otherwise. The C compiler assumes that the linker will find your function later while linking. And, this will happen if you link the correct .o file.
hth
KnarfB
2023-02-06 02:32 AM
> But I get the following error.
No, you get a warning. The compiler doesn't see a declaration of add2Num unless you include a .h file or declared add2Num otherwise. The C compiler assumes that the linker will find your function later while linking. And, this will happen if you link the correct .o file.
hth
KnarfB
2023-02-06 03:08 AM
extern int add2Num(int num1, int num2);
int main()
{
....
}
Thank you KnarfB for ur response.
Yes you are right. I had to declare the function name before the int main()
And it worked.