Mail Archives: djgpp/1999/06/15/07:01:19
An '.o' files is an *object file*, that is, a file containing compiled
code. So, when you compiled a .C file, the resulting .o file contains
all the functions from the .C file in the form of compiled code.
As for why you wouldn't just include files with function definitions,
this one is a little more tricky. I used to try and do this myself.
One reason not to do it is because if you change one thing slightly,
you have to recompile the whole program (not just the file you
changed).
The other general problem is that you encounter difficultied with
forward references. Using the example you gave, what if functions in
"flowers.h" needed to call functions in "kickass.h" and vice-versa?
You would have to put explicit declarations in on or the other (in
flowers.h to maintain current order of inclusion). If you had
flowers.c and kickass.c as seperate files, however, with corresponding
headers flowers.h and kickass.h, then you would have no problem as in
flowers.c you would just
#include "kickass.h"
and in kickass.c you would
#include "flowers.h"
So, there are some subtle reasons why you shouldn't include function
bodies in header files.
Davin.
On Mon, 14 Jun 1999 16:54:09 -0700, "Al Morgan" <muaddib AT proaxis DOT com>
wrote:
>I know a .o file is something that comes in between the .cpp and the .exe,
>but what it is exactly?
>
>Also, what is the point of using makefiles, when I can just use a whole
>bunch of header files? Like this:
>
>#include <ai.h>
>#include <flowers.h>
>#include <kickass.h>
>
>void main()
> {
> ...
> }
>
>Where the header files would contain everything I would nee.
__________________________________________________________
*** davmac - sharkin'!! davmac AT iname DOT com ***
my programming page: http://yoyo.cc.monash.edu.au/~davmac/
- Raw text -