home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 3848 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.8 KB  |  63 lines

  1. Path: sn.no!not-for-mail
  2. From: christon@sn.no (Christopher Naas)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: sprintf in library
  5. Date: 19 Feb 1996 15:53:06 +0100
  6. Organization: SN Internett
  7. Message-ID: <1593.6623T953T661@sn.no>
  8. NNTP-Posting-Host: sinsen.sn.no
  9. X-Newsreader: THOR 2.21 (Amiga;SOUP)
  10.  
  11. I'm having problems using sprintf() with floating point values in a shared
  12. library.
  13.  
  14. The smakefile for the library is:
  15.  
  16. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  17. all: Memory.kbb
  18.  
  19. Memory.o: Memory.c
  20.    sc libcode nostackcheck smallcode smalldata strmerge opt Memory.c gst
  21. include:all.gst math ffp
  22.  
  23. Memory.kbb: Memory.o
  24.    sc link Memory.o startup=libinit noicons to Memory.kbb libfd
  25. KarmaBar:BarItems/kbBarItem.fd libversion 1 librevision 0
  26. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  27.  
  28.  
  29. I open mathffp.library in my program and give MathBase to the shared library
  30.  
  31. #define MathBase  mystruct->MathBase
  32.  
  33.  
  34. .. this works fine for dos.library, intuition.library and so on.
  35.  
  36.  
  37. The problem is this. In my library, I use floating point numbers, and sprintf
  38. a calculation to a string, like this:
  39.  
  40. sprintf (string, "%s %.2f%s\0", Prefix, c/1024/1024, Suffix);
  41.  
  42. 'c' is a float. The library works fine when I comment out this string, but
  43. crashes if it's there (even if it's not run!).
  44.  
  45. BTW: Just c = c/1024/1024; works fine. As long as I don't call sprintf, it
  46. works, so I guess it's the %.2f thing that's causing my problems.
  47.  
  48. ...
  49.  
  50.  
  51. The main program is also compiled with math=ffp, and I manually Open and Close
  52. the mathffp.library (MathBase).
  53.  
  54.  
  55. So, my question is this; why doesn't it work? It works for all other
  56. libraries, so why not for mathffp.library?
  57.  
  58.  
  59. --
  60. Christopher Landmark Naas    o  EMail: christon@sn.no
  61. LoungeBar Development        o  WWW:   http://www.sn.no/~christon/
  62. Former Reg. Amiga Developer  o  IRC:   KarmaComa
  63.