A function is declared with 2 arguments, but the definition has only 1 argument
The HCS12 compiler does not throw an error or warning
CodeWarrior IDE version 5.9.0 build 5294
解決済! 解決策の投稿を見る。
Hi Erich,
Thank you for the reply
Enabling C++ in Compiler options does detect this
Thanks
Surabi
Hello,
can you please send me a demo project of this problem?
Thanks!
Have a great day,
Jennie Zhang
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
I have a main.c file which calls the function add
The function add is declared in add.h and defined in add.c
I have added all these files in the project
I don't get an error when I compile the project
Hi Alice,
The declaration in add.h has 2 arguments
The definition in add.c has just 1 argument
When I call the function in main.c, I am passing 2 arguments which would result in error
I was expecting an error or warning "wrong number of arguments"
Hi Surabi,
I have to disagree that this is a compiler bug/error. You are missing to include
#include "add.h"
inside add.c.
According to the C language, the compiler won't be able (and shall not) produce an error for this. The linker has no chance to detect this neither. If you want to catch something like this, you would have to compile your sources in C++ mode.
I hope this helps,
Erich
Hi Erich,
Thank you for the reply
Enabling C++ in Compiler options does detect this
Thanks
Surabi