Article View: comp.sys.amiga.tech
Article #6882Re: C compilers code generation
From: GIAMPAL
Date: Wed, 21 Nov 1990 01:49
Date: Wed, 21 Nov 1990 01:49
26 lines
1659 bytes
1659 bytes
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
Technical Details
Message-ID:
<90324.204949GIAMPAL@auvm.auvm.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!elroy.jpl.nasa.gov!usc!julius.cs.uiuc.edu!wuarchive!psuvax1!psuvm!auvm!giampalReferences:
<dillon.7256@overload.Berkeley.CA.US> <1990Nov15.170810.5868@sisd.kodak.com> <dillon.7260@overload.Berkeley.CA.US> <1990Nov19.130657.19380@sisd.kodak.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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: <dillon.7256@overload.Berkeley.CA.US> <1990Nov15.170810.5868@sisd.kodak.com> <dillon.7260@overload.Berkeley.CA.US> <1990Nov19.130657.19380@sisd.kodak.com> Organization: The American University - University Computing Center Lines: 26