Article View: comp.sys.amiga.tech
Article #6887Re: C compilers code generation
From: Ed Hanway
Date: Wed, 21 Nov 1990 13:12
Date: Wed, 21 Nov 1990 13:12
25 lines
1484 bytes
1484 bytes
GIAMPAL@auvm.auvm.edu writes:
>In article <1990Nov19.130657.19380@sisd.kodak.com>, jeh@sisd.kodak.com (Ed
>Hanway) says:
>>#define SAY(s) Write(backstdout, s, strlen(s))
>#define MSG(s) { char *s; Write(Output(), s, strlen(s)); }
>
>This way you only get one copy of the string constant, and you get a nice
>function.
I guess you really mean
#define MSG(s) { char *tmp = s; Write(whatever, tmp, strlen(tmp)); }
which is fine, but my version was posted as an example of when a builtin
version of strlen() came in handy. In Lattice (now SAS) C, strlen("constant")
is evaluated at compile time, so, using my version, SAY("foo") would
compile as Write(backstdout, "foo", 3). This not only eliminates the
extra copy of the string constant, it eliminates the strlen() operation
altogether.
--
Ed Hanway --- uunet!sisd!jeh
This message is packed as full as practicable by modern automated equipment.
Contents may settle during shipment.
Technical Details
Message-ID:
<1990Nov21.131206.2634@sisd.kodak.com>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!udel!rochester!kodak!sisd!jehReferences:
<dillon.7260@overload.Berkeley.CA.US> <1990Nov19.130657.19380@sisd.kodak.com> <90324.204949GIAMPAL@auvm.auvm.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!udel!rochester!kodak!sisd!jeh From: jeh@sisd.kodak.com (Ed Hanway) Newsgroups: comp.sys.amiga.tech Subject: Re: C compilers code generation Message-ID: <1990Nov21.131206.2634@sisd.kodak.com> Date: 21 Nov 90 13:12:06 GMT References: <dillon.7260@overload.Berkeley.CA.US> <1990Nov19.130657.19380@sisd.kodak.com> <90324.204949GIAMPAL@auvm.auvm.edu> Sender: news@sisd.kodak.com Organization: Printer Products Division Eastman Kodak Lines: 25