From: kalyniuk AT telusplanet DOT net Newsgroups: comp.os.msdos.djgpp Subject: Re: Library problem? Message-ID: <39029b14.12321442@news.telusplanet.net> References: <3900d15d DOT 7050493 AT news DOT telusplanet DOT net> <8dsbvo DOT 3vvpilr DOT 0 AT buerssner-17104 DOT user DOT cis DOT dfn DOT de> X-Newsreader: Forte Free Agent 1.21/32.243 Lines: 100 Date: Sun, 23 Apr 2000 14:45:08 GMT NNTP-Posting-Host: 161.184.233.238 X-Trace: news0.telusplanet.net 956501108 161.184.233.238 (Sun, 23 Apr 2000 08:45:08 MDT) NNTP-Posting-Date: Sun, 23 Apr 2000 08:45:08 MDT To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Hi again, I solved my problem but I still don't understand why my program compiled and linked without complaining. What happened was when I first built my lib I copied it from my working directory into DJGPP\LIB. In my project where I was using it, I told RHIDE to look there for it. When I changed and rebuilt the lib the changes were made in my working directory copy but not in the DJGPP\LIB copy. When I told RHIDE to look in DJGPP\WORK for the lib everything works fine. Duh! However, the only change I made was to change the variable 'bore' from an int to a float. I would have thought that the compiler or linker should have thrown up an error or warning or something and that my program should have at least shown a garbage value (I did use printf to debug) returned from the function rather than just ignoring it and leaving it at zero. Anyway thanks for the response. Mike. On 22 Apr 2000 12:35:22 GMT, buers AT gmx DOT de (Dieter Buerssner) wrote: >kalyniuk AT telusplanet DOT net wrote: > >[With RIDE] >>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. > >I don't use RIDE, so I am speculating a bit here. >Debugging code with floating point may be tricky. Gcc seems to >not generate enough debug information, to let the debugger >trace some values all the time. When debugging with gdb, compiling >the source with -ggdb -ffloat-store and linking with -ggdb >can make debugging of floating point code easier. > >If you do understand x87 assembly and/or the FPU, inspecting >the FPU registers directly can also help. In gdb use "info float", >in fsdb "ALT-n", don't know about Rhide, sorry. > >An other option is of course, to put a debuggin printf into >the source. > >>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))); > >For debugging, add > > printf("press = %d, bore = %g, force = %g\n", press, bore, force); > >> return force; >>} >> >>In my project source is the following: > >I assume, you have a prototype > >float cyl_ext_force(int, float); > >in either the source or some included header here. Yes? > >>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); > >I haven't used scanf for a long time (only sscanf), but I think > >scanf("%f", &cyl_1.bore); > >should be used here. (Without the "\n") > >>puts("Enter working pressure:"); >>scanf("%d\n",&cyl_1.press); > >See above. > >>ext_force=cyl_ext_force(cyl_1.press, cyl_1.bore); >> >>printf("\nExtend force is %.2f lbs", ext_force); > >Depending on context you might need > >fflush(stdout); > >>Why does the value of ext_force never change from zero? Am I >>overlooking something obvious or what? > >Seems to work here. Did you try without the library, by >pasting the code in the library directly into the source?