home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / unix / bsd / 8445 < prev    next >
Encoding:
Text File  |  1992-11-04  |  1.9 KB  |  45 lines

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