`static'
Chris Torek
chris at mimsy.UUCP
Mon Aug 8 14:06:54 AEST 1988
In article <12840 at mimsy.UUCP> [and why does our netnews software use .UUCP?]
I wrote:
>>string constants ... do, however, have static storage duration ....
In article <255 at quintus.UUCP> jbeard at quintus.uucp (Jeff Beard) writes:
>1) program scoped static char * foo may be altered anywhere by any procedure
> and thus the original string reference will be lost to all, even though
> the string it self persists.
[example deleted]
Certainly.
>2) which brings up another storage class often forgotten altogeter:
> READONLY as in a format string given for printf()
In the dpANS, read-only (called `const') is considered a `qualifier'
rather than a storage class. Strangely, while "string"s are allowed
to be read-only, they have type `array of char' rather than `array of
const char'. (I think this is a mistake.)
> printf("text %c not of type %s\n" args, ..);
> xstr() collects said strings to reduce storage costs at possible
> expense of memory thrashing to get at a non-local page.
The xstr program actually collects *all* quoted strings, and replaces
each with something of the form `&xstr[<constant>]'. This is annoying;
the common sequence
#ifndef lint
static char sccsid[] = "@(#)blort.c 4.2 (Berkeley) 8/8/88";
#endif
fails to compile, since it becomes
static char sccsid[] = &xstr[234];
One must write
static char *sccsid = "@(#)blort.c 4.2 (Berkeley) 8/8/88";
which wastes a few bytes of storage per sccsid (since each id is
different).
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain: chris at mimsy.umd.edu Path: uunet!mimsy!chris
More information about the Comp.lang.c
mailing list