delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/06/04/01:21:05

From: mschulter AT DOT value DOT net (M. Schulter)
Newsgroups: comp.os.msdos.djgpp
Subject: Emacs IDE copes with quirky file
Date: 3 Jun 1997 23:07:26 GMT
Organization: Value Net Internetwork Services Inc.
Lines: 59
Message-ID: <5n283e$e4l$1@vnetnews.value.net>
NNTP-Posting-Host: value.net
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Hi, everyone.

Now and then, djgpp users might enjoy a minor success story, and this
one may illustrate both the importance of including the right
libraries, and the user-friendliness of the Emacs IDE in coping with
C sources on the Net that do ANSIcally incorrect things.

Yesterday a friend e-mailed me a tutorial program from the Net. The
program was for a simple trigonometric calculator that takes an input
like

progname sin 1.45

and displays the result.

Well, I pulled it up in Emacs, and used my F7 macro to compile with a
standard makefile. At first I noticed mainly two very typical
warnings: adding 'int' before 'main', and adding the prudent line

return(0);

at the end of main(), got rid of these warnings.

However, there was still a third warning, cautioning me about an
implicitly declared function: atof.

At first, I thought that this might just be some ANSI nicety, but when
I tried to run the program I learned quite otherwise <grin>.
Regardless of the value in radians I choose for a given trigonometric
function such as sin or cos, the program always reported the same
single value for that function.

Now I guessed at the problem: there was a library that this source
wasn't including that _should_ be included with that atof. Trying my
trusty C-h i, I was in Info, and soon found out that atof is located
in stdlib.h.

Then I just added that vital line

#include <stdlib.h>

and pressed F7 again -- and the program actually worked as intended.

Why a tutorial example wouldn't include stdlib.h for atof, I'm not
sure: but the Emacs IDE and GCC worked together nicely to solve the
problem -- even though I had no idea of what 'atof' was or what it
might do when I first looked at this source.

Thanks to the GNU and djgpp folks who make all this possible.

Most appreciatively,

Margo Schulter
mschulter AT value DOT net

(Please remove the extra . from my default e-mail address)



- Raw text -


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