home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / c / 16594 < prev    next >
Encoding:
Text File  |  1992-11-16  |  1.6 KB  |  45 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!taumet!steve
  3. From: steve@taumet.com (Steve Clamage)
  4. Subject: Re: Idle Questions about ANSI C
  5. Message-ID: <1992Nov14.162633.13199@taumet.com>
  6. Organization: TauMetric Corporation
  7. References: <1992Nov13.213708.5456@mccc.edu>
  8. Date: Sat, 14 Nov 1992 16:26:33 GMT
  9. Lines: 34
  10.  
  11. pjh@mccc.edu (P. J. Holsberg) writes:
  12.  
  13. >1) Is "size_t" ever not the same as "unsigned int"? If so, in what situation?
  14.  
  15. If the address space is large but ints are small, size_t will be unsigned
  16. long.  If address space is small but ints are large, you might want to
  17. make size_t an unsigned short.  I've seen implementations like the first
  18. case.  The second case seems unlikely.  Both could be Standard-conforming.
  19.  
  20.  
  21. >2) Is there ever a need for a static array defined inside a function in
  22. >ANSI C? I.e.,
  23.  
  24. >int func(char c, int i)
  25. >{
  26. >    static char name[30];
  27. >    ...
  28. >}
  29.  
  30. This has nothing to with ANSI C.  The question is whether you want the
  31. variable to retain its value across function calls, even recursive ones.
  32.  
  33. A local static has the same semantics as a file-level static, but its
  34. visibility (scope) is limited.  It is hidden from other functions in the
  35. same module (or possibly from other blocks in the same function).
  36.  
  37. Use a local static when you want to retain state information across calls
  38. to the function and want to hide the variable from other functions (or
  39. other scopes).  I don't see why an array would be either more or less
  40. likely to fit into this category than any other data type.
  41. -- 
  42.  
  43. Steve Clamage, TauMetric Corp, steve@taumet.com
  44. Vice Chair, ANSI C++ Committee, X3J16
  45.