Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!uakari.primate.wisc.edu!ginosko!uunet!sdrc!mustard From: mustard@sdrc.UUCP (Sandy Mustard) Newsgroups: comp.lang.c Subject: Re: How Does 'C' Store Strings ? Message-ID: <914@sdrc.UUCP> Date: 16 Oct 89 23:34:28 GMT References: <2141@avsd.UUCP> <2157@avsd.UUCP> Organization: SDRC, Cincinnati Lines: 39 In article <2157@avsd.UUCP>, childers@avsd.UUCP (Richard Childers) writes: > I recently said ... > > char vers[CMDBUFSIZ] = "v1.00 891010 richard childers" ; > > > The best help I've gotten to date suggested that I use 'static' storage > classes for SCCS-type buried ID strings > > One possibility that's occurred to me is that, in a PC environment, the > designers of the compiler might have decided that string compression was > a win, much as ( according to many contributors ) Lattice' compiler tries > to identify and eliminate redundant strings from the resulting image, > given the significant decrease in space available in an MS-DOS environ- > -ment. You may also want to use static const char vers..... ^^^^^ This may help avoid the redundant string elimination. Would not the following be true. static char string1[] = "ABCD"; static char string2[] = "ABCD"; The compiler could eliminate the redundant strings (when appropriate) whereas: static const char string1[] = "ABCD"; static char string2[] = "ABCD"; should force the compiler to store two separate strings. (I hope someone will correct me if I'm wrong.:-)) Sandy