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