delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/06/15/07:01:19

From: DavMac AT iname DOT com (Davin McCall)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Of Makefiles and Object Files
Date: Tue, 15 Jun 1999 02:31:25 GMT
Organization: Monash Uni
Lines: 54
Distribution: world
Message-ID: <3765b8c4.1607046@newsserver.cc.monash.edu.au>
References: <929404509 DOT 389 DOT 11 AT news DOT remarQ DOT com>
NNTP-Posting-Host: damcc5.halls.monash.edu.au
X-Trace: towncrier.cc.monash.edu.au 929413850 31995 130.194.198.138 (15 Jun 1999 02:30:50 GMT)
X-Complaints-To: abuse AT monash DOT edu DOT au
NNTP-Posting-Date: 15 Jun 1999 02:30:50 GMT
X-Newsreader: Forte Free Agent 1.1/32.230
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019