home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.bsd
- Path: sparky!uunet!munnari.oz.au!cs.mu.OZ.AU!nareen.acci.com.au!ggr
- From: ggr@nareen.acci.com.au (Greg Rose)
- Subject: Re: mktemp - Bus Error.
- Message-ID: <9231017.24452@mulga.cs.mu.OZ.AU>
- Sender: news@cs.mu.OZ.AU
- Organization: Australian Computing and Communications Institute
- References: <1992Nov2.210351.12723@ee.ryerson.ca> <1992Nov2.215333.1434@Princeton.EDU> <KHERA.92Nov3111245@thneed.cs.duke.edu> <1992Nov3.174359.19262@Princeton.EDU>
- Date: Thu, 5 Nov 1992 06:49:59 GMT
- Lines: 33
-
- In article <1992Nov3.174359.19262@Princeton.EDU> jsm@shade.Princeton.EDU (John Scott McCauley Jr.) writes:
- >In article <KHERA.92Nov3111245@thneed.cs.duke.edu> khera@cs.duke.edu (Vivek Khera) writes:
- >[on mktemp]
- >>you don't need something so complicated. how about this:
- >>
- >> char tmpname[] = "/tmp/foo.XXXXXX";
- >> mktemp(tempname);
- >[should be tmpname]
- >>
- >
- >Careful -- it doesn't work for some C-compilers:
- >"t.c", line 3: no automatic aggregate initialization
- >"t.c", line 3: illegal lhs of assignment operator
- >
- >Program defensively! I'd rather have something complicated that works!
- >
-
- I think there is a misunderstanding here. "line 3" is either legal C,
- and always has been, or illegal C, and still is, depending on where
- the line is.
-
- The word "automatic" in the error message refers to the storage class
- of the variable "tmpname". If line 3 appears inside a function, the
- storage class assumed is "auto", and no, you can't copy around arrays
- like that in C. If line 3 is outside a function, the storage class
- assumed is "extern", and the statement becomes an initialisation of
- the array (not any sort of assignment), and has been legal C since at
- least 1975. No C compiler could refuse it.
-
- --
- Greg Rose Australian Computing and Communications Institute
- ggr@acci.com.au +61 18 174 842
- `Use of the standard phrase "HIJACKED" may be inadvisable' -- CAA
-