home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!munnari.oz.au!cs.mu.OZ.AU!munta.cs.mu.OZ.AU!fjh
- From: fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON)
- Subject: Re: typedef and memory allocation
- Message-ID: <9225523.27157@mulga.cs.mu.OZ.AU>
- Sender: news@cs.mu.OZ.AU
- Organization: Computer Science, University of Melbourne, Australia
- References: <3687@amethyst.math.arizona.edu>
- Distribution: usa
- Date: Fri, 11 Sep 1992 13:04:28 GMT
- Lines: 44
-
- winfree@math.arizona.edu (Art Winfree) writes:
-
- >typedef double vector[3]
-
- There should be a semicolon at the end of the above typedef.
-
- >main()
- >{
- >.
- >.
- >.
- >}
- >
- >funky_func()
- >{
- >vector bigarray[100];
- >.
- >.
- >.
- >}
- >
- >Question: Shouldn't a reasonable C compiler allocate enough
- >(3*100*sizeof(double)) memory for bigarray for use when funky_func()
- >is called? Evidently mine doesn't, since the code core dumps unless I
- >explicitly calloc in funky_func().
-
- Either your compiler is broken, or there is a bug somewhere else in your code.
- (ie. in the elided part).
-
- The only other possibility I can think of is that you might just possibly
- be getting a stack overflow, but that seems highly unlikely.
-
- >I know typedef itself doesn't
- >cause any allocation, but are typedef'd types, as above, supposed to
- >be sizeof'd and variables invoking them given appropriate memory, even
- >if included in local function array definitions?
-
- Yes, they are.
-
- --
- Fergus Henderson fjh@munta.cs.mu.OZ.AU
- This .signature virus is a self-referential statement that is true - but
- you will only be able to consistently believe it if you copy it to your own
- .signature file!
-