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