Originally Posted by
Meloshski
Allos all, I have a question about header files.
What must be understood here is that a header is an interface. Let's try to make it clear.
The C language being 'function oriented' (aka prodcedural), the main entity is the function (isn't the main() function the entry point of any C program). Hence, the code is generally organized into functions calling other functions.
When you write a function, you use a 'function header'
Code:
<return type> <function name> ([<parameters>])
and a function body
Code:
{
<locals, instructions etc.>
}
The function header actually describes the interface of the function.
- How to call it (the name)
- What the entry parameters are (type, number, order)
- What is returned
This header can be detached from the function an put in some file called a 'header file' (with the .h extension).
Hence you have, on one hand, the header file with the separated functions headers (aka 'prototypes' in modern C, the 'declaration' style being deprecated),
Code:
<return type> <function name> ([<parameters>]);
and, on the other hand, the implementation files (.c or whatever, could be assembly or another language) that hold the bodies of the functions, aka 'definition' or 'implementation'.
Code:
<return type> <function name> ([<parameters>])
{
<locals, instructions etc.>
}