Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!mit-eddie!bloom-beacon!eru!hagbard!sunic!mcsun!hp4nl!philapd!ssp9!dolf From: dolf@idca.tds.PHILIPS.nl (Dolf Grunbauer) Newsgroups: comp.sys.amiga.tech Subject: Re: C compilers code generation Message-ID: <530@ssp9.idca.tds.philips.nl> Date: 22 Nov 90 08:06:21 GMT References: <1990Nov19.130657.19380@sisd.kodak.com> <90324.204949GIAMPAL@auvm.auvm.edu> <1990Nov21.131206.2634@sisd.kodak.com> Reply-To: dolf@idca.tds.philips.nl (Dolf Grunbauer) Organization: Philips Information Systems, Apeldoorn, The Netherlands Lines: 22 In article <1990Nov21.131206.2634@sisd.kodak.com> jeh@sisd.kodak.com (Ed Hanway) writes: >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). Our compiler (for Unix, not for my Amiga) allows 'sizeof("constant")' which is eliminated at compile time. This obviously doesn't work for dynamic strings. -- _ _ / U | Dolf Grunbauer Tel: +31 55 433233 Internet dolf@idca.tds.philips.nl /__'< Philips Information Systems UUCP ...!mcsun!philapd!dolf 88 |_\ If you are granted one wish do you know what to wish for right now ?