Path: utzoo!attcan!uunet!husc6!uwvax!oddjob!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.lang.c Subject: Re: `static' Message-ID: <12891@mimsy.UUCP> Date: 8 Aug 88 04:06:54 GMT References: <644@m10ux.UUCP> <503@draken.nada.kth.se> <12840@mimsy.UUCP> <255@quintus.UUCP> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 45 In article <12840@mimsy.UUCP> [and why does our netnews software use .UUCP?] I wrote: >>string constants ... do, however, have static storage duration .... In article <255@quintus.UUCP> jbeard@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[]'. 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@mimsy.umd.edu Path: uunet!mimsy!chris