Dear All:
I can build and link This project. But the main.c file call test() function, and test() funcion is located in A.c file. Test() function is defined in A.c and declared in A.h. I find main.c not including A.h And all files except A.c don't include A.h file.
I can not understand:why the project can been builded and linked, since that we didn't write A.h sentence in project.
Please help me.
Solved! Go to Solution.
Hello
The compiler follows the C89 standard, which allows you to invoke a function even though you did not declare a prototype for this function earlier.
You can configure the compiler to generate a message in that case.
The option to be used depends on the MCU you are targeting. For HCS08 or HCS12, HCS12X you can use the option -Wpd.to get a warning message when a prototype is missing.
CrasyCat
Hello
The compiler follows the C89 standard, which allows you to invoke a function even though you did not declare a prototype for this function earlier.
You can configure the compiler to generate a message in that case.
The option to be used depends on the MCU you are targeting. For HCS08 or HCS12, HCS12X you can use the option -Wpd.to get a warning message when a prototype is missing.
CrasyCat
Hi,Dear Sir,
1. Just like what you said, though build and link okay, a warning: C1801: Implicit parameter-declaration for 'test' ... will occur.
2. The whole project is from my friend. I want to create one file BB.c and BB.h,and define MyFunc in BB.c and declared it in BB.h, and write include "BB.h" in BB.c, and then call MyFunc in main.c, not include BB.h in main.c. But build wrong, can not finish.
3. How to implement option -Wpd in setting window?
Thanks.
Hello
- Which CPU are you targeting (HC08, HC12, Coldfire, ..)
- Which version of CodeWarrior are you using?
CrasyCat
MCU:9s12x.
CodeWarrior:5.9.0
Hello
To activate the option which generate an error message when function prototype is missing follow these steps:
- Open your project in CodeWarrior
- Open the Target Settings dialog (press ALT+F7)
- Go to Target > Compiler for HC12 panel.
- Click on the Options button.
- Switch to the Message tab.
- Scroll down in the list box and check Error for implicit parameter declaration.
- Click OK to close the HC12 Compiler Option settings dialog.
- Click OK to close the Target Settings dialog.
CrasyCat
Hi Tom,
. . . and then call MyFunc in main.c, not include BB.h in main.c.
If you wish to call "MyFunc" from "main.c", then you should include "BB.h" in "main.c" as well. That is the purpose of a .h file.
A good book on "C" is called for.