www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/01/27/17:15:37

From: Martin Ambuhl <mambuhl AT earthlink DOT net>
Newsgroups: comp.os.msdos.djgpp,alt.comp.lang.learn.c-c++
Subject: Re: Problem implementing multiple moduled program
Date: Wed, 27 Jan 1999 17:04:29 -0500
References: <36b41be7 DOT 2525182 AT news> <36AE2EF6 DOT 3AC3 AT seidata DOT com> <36b05fef DOT 19943524 AT news> <36af6725 DOT 21789350 AT news>
X-Posted-Path-Was: not-for-mail
X-Accept-Language: en
X-ELN-Date: 27 Jan 1999 22:04:32 GMT
X-ELN-Insert-Date: Wed Jan 27 14:05:05 1999
Organization: Nocturnal Aviation
Lines: 34
Mime-Version: 1.0
NNTP-Posting-Host: 1cust156.tnt12.nyc3.da.uu.net
Message-ID: <36AF8D6D.32C47958@earthlink.net>
X-Mailer: Mozilla 4.5 [en] (Win95; I)
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Stuart Hall wrote:
> 
> I figured it out - DJGPP specific issue, I had added getsafe.h to my
> project list - apparently it was trying to compile getsafe.h -- as
> soon as I removed it from my project list, all worked well.

Well, at least you learned not to place headers in your project. 
Consider that the compiler wants to see translation units.  The #include
directive places the text of "getsafe.h" into the including translation
unit.  "getsafe.h" has no independent contribution.
> 
> I would still like to know if my method of creating this separate
> function is the most efficient way of writing programs - both in terms
> of my typing time and run time.
> 
> Also, how about my implementation of "getsafe" as a separate linkable
> program.  Is this a good idea?  Jack and James -- I'd like your input
> since this program is based upon your ideas of a safe "gets" function.

It is a very good idea to separate reusable functions into separate
translation units.  This is normal.  It is extended to separate
compilation without linking giving you a getsafe.o file which (from the
command line) could be used as 
   gcc -O main.c getsafe.o -O multiple.exe
This bypasses the need to repeatedly translate getsafe.c.
With enough of these objects files, you may want to create a library of
them (see ar in your implementation).

Your program still has errors.  See my other post, and turn up the
diagnostic level.

-- 
Martin Ambuhl (mambuhl AT earthlink DOT net)
Note: mambuhl AT tiac DOT net will soon be inactive

- Raw text -


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