Path: utzoo!attcan!uunet!cbmvax!bagate!dsinc!unix.cis.pitt.edu!zaphod.mps.ohio-state.edu!swrinde!ucsd!pacbell.com!ames!haven!decuac!bacchus.pa.dec.com!bacchus!mwm From: mwm@raven.relay.pa.dec.com (Mike (My Watch Has Windows) Meyer) Newsgroups: comp.sys.amiga.tech Subject: Re: C compilers code generation Message-ID: Date: 21 Nov 90 18:29:09 GMT References: <1990Nov15.170810.5868@sisd.kodak.com> <1990Nov19.130657.19380@sisd.kodak.com> <90324.204949GIAMPAL@auvm.auvm.edu> Sender: news@wrl.dec.com (News) Organization: Missionaria Phonibalonica Lines: 28 In-Reply-To: GIAMPAL@auvm.auvm.edu's message of 21 Nov 90 01:49:49 GMT In article <90324.204949GIAMPAL@auvm.auvm.edu> GIAMPAL@auvm.auvm.edu writes: In article <1990Nov19.130657.19380@sisd.kodak.com>, jeh@sisd.kodak.com (Ed Hanway) says: >I'd never use strlen("constant") either, unless I knew that it was >evaluated at compile time. I have used (albeit in a toy program): > >#define SAY(s) Write(backstdout, s, strlen(s)) > >which works for both SAY("const") and SAY(var). Yes this does work, but if the string is a constant, then you get a duplicate copy of the string put in your data segment. I use : #define MSG(s) { char *s; Write(Output(), s, strlen(s)); } So use the flag on your compiler that forces identical string constants into the same string. That way, you don't have the extraneous variables (and manipulations thereof) in your code. Or take the approach of one programmer I knew - he never coded string constants, except for the place where he defined a variable to point to them. But the compiler can do that for you.