Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!elroy.jpl.nasa.gov!usc!julius.cs.uiuc.edu!wuarchive!psuvax1!psuvm!auvm!giampal From: GIAMPAL@auvm.auvm.edu Newsgroups: comp.sys.amiga.tech Subject: Re: C compilers code generation Message-ID: <90324.204949GIAMPAL@auvm.auvm.edu> Date: 21 Nov 90 01:49:49 GMT References: <1990Nov15.170810.5868@sisd.kodak.com> <1990Nov19.130657.19380@sisd.kodak.com> Organization: The American University - University Computing Center Lines: 26 In article <1990Nov19.130657.19380@sisd.kodak.com>, jeh@sisd.kodak.com (Ed Hanway) says: >dillon@overload.Berkeley.CA.US (Matthew Dillon) writes: >> Uh, I NEVER use strlen() on a string constant. That's the most >> ridiculous thing I've ever heard of in my life! >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)); } (note: those are supposed to be curly braces, but this is an APL keyboard, so I don't know what it will be on your screen) This way you only get one copy of the string constant, and you get a nice function. BTW, don't use MSG() if you are running from WB with no output file handle, you'll hang (a definite bug in WB, IMHO). --dominic