home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / c / 12250 < prev    next >
Encoding:
Text File  |  1992-08-12  |  1.6 KB  |  43 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!usc!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!uchinews!quads!pynq
  3. From: pynq@quads.uchicago.edu (George Jetson)
  4. Subject: Prototypes: Aren't they supposed to catch me when I do this?
  5. Message-ID: <1992Aug12.184222.5226@midway.uchicago.edu>
  6. Summary: (I know this is a stupid question - Don't waste time flaming me)
  7. Sender: news@uchinews.uchicago.edu (News System)
  8. Reply-To: pynq@midway.uchicago.edu
  9. Organization: D. J. Dougherty & Associates
  10. Date: Wed, 12 Aug 1992 18:42:22 GMT
  11. Lines: 30
  12.  
  13. I am writing a (very small, but its a prototype for someting bigger)
  14. program in Borland C++ (2.0).
  15.  
  16. I have <include>d stdio.h, stdlib.h, string.h, and malloc.h.
  17. <malloc.h> includes a prototype for calloc:
  18.  
  19.     void _FAR *_Cdecl calloc (size_t __nitems, size_t __size);
  20.  
  21. And size_t is typedef'd to unsigned (16 bits in this environment).
  22.  
  23. Now, I (stupidly) wrote:
  24.  
  25.     long n;
  26.     somepointer = calloc(n = atol(somestring),sizeof(struct something));
  27.  
  28. Which didn't work (but it compiled clean) because the first arg is a
  29. long.  Changing the declaration of n to size_t (& atol to atoi) fixed
  30. the problem.
  31.  
  32. Now, my question is, shouldn't I have gotten at least a warning from the
  33. compiler about this?
  34.  
  35. ************************************************************************
  36. Please don't drink the battery acid, it tastes bad and will hurt you.
  37. Also, don't bite the tyres, especially when the bike is moving.
  38. (Our lawyers made us put this in this manual.)
  39.  
  40.     - pynq@quads.uchicago.edu, who is still costing the net
  41.       hundreds, if not thousands, of dollars, every time he posts -
  42. ************************************************************************
  43.