Quote:
Originally posted by Venkatesh
Ifi_utilities.c seems to contain "useful" functions which we can call in our code. This behavior seems similar to that of a library or header file.
|
This is correct - it is a library.
Quote:
|
If I am right in thinking so, why isn't it a header file?
|
There is also a header file (ifi_utilities.h) included in the distribution. A header file is used by other source (.c) files to know what the function names are and what the arguments are. This is because the header files contain function declarations:
Code:
void Wait4TXEmpty(void);
void PrintByte(unsigned char odata);
void PrintWord(unsigned int odata);
However, the declarations only tell the C compiler what the functions
are, not what they
do. That is what the function
definition is for:
Code:
void PrintByte(unsigned char odata)
{
Hex_output((unsigned char) odata);
TXREG = 13; /* a carriage return */
Wait4TXEmpty();
}
Function definitions belong in C files, function declarations belong in header (.h) files. It is possible to put code into header files, however there are many problems with this and it is widely considered to be a very bad thing to do.
Sorry if I oversimplified it, but maybe this will help other people understand the difference a little better too...