Mail Archives: djgpp/1999/01/27/17:15:37
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 -