delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/04/21/18:13:12

From: kalyniuk AT telusplanet DOT net
Newsgroups: comp.os.msdos.djgpp
Subject: Library problem?
Message-ID: <3900d15d.7050493@news.telusplanet.net>
X-Newsreader: Forte Free Agent 1.21/32.243
Lines: 50
Date: Fri, 21 Apr 2000 22:42:49 GMT
NNTP-Posting-Host: 161.184.232.20
X-Trace: news0.telusplanet.net 956356969 161.184.232.20 (Fri, 21 Apr 2000 16:42:49 MDT)
NNTP-Posting-Date: Fri, 21 Apr 2000 16:42:49 MDT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

HI all, hope you can help me with this.
I've built a small librabry yet I can't seem to use the functions in
it. Heres whats happening: I built the library, no complaints
everything fine. I start a project, add the library by adding it to
the libraries list in RHIDE. (The lib is named libhyd.a so I just put
hyd and checked the box). Now when I use a function from my lib in my
new project it compiles (-Wall) and links fine. No complaints
anywhere. When I run the prog, the function does absolutely nothing.
So now for some debugging. I watch the variable that my function
should change, step through the prog and find that the variable does
not change. It is still zero (as initialized). I can watch other
variables and see them change so it's not a problem with the debugger.


Heres a snippet of code

*********************************
In the library is this function

float cyl_ext_force(int press, float bore)
{
	float force=0;
	force=press * (3.1415 * ((bore/2)*(bore/2)));
	return force;
}

In my project source is the following:

float ext_force=0;
struct cylinder{
	float bore;
	float rod;
	int press;
	};
	struct cylinder cyl_1;

puts("Enter bore size:");
scanf("%f\n", &cyl_1.bore);
puts("Enter working pressure:");
scanf("%d\n",&cyl_1.press);

ext_force=cyl_ext_force(cyl_1.press, cyl_1.bore);

printf("\nExtend force is %.2f lbs", ext_force);

Why does the value of ext_force never change from zero? Am I
overlooking something obvious or what?

Thanks,
Mike Kalyniuk

- Raw text -


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