Article View: comp.sys.amiga.tech
Article #7100Re: C compilers code generation
From: Matthew Dillon
Date: Tue, 27 Nov 1990 03:58
Date: Tue, 27 Nov 1990 03:58
48 lines
2010 bytes
2010 bytes
In article <90324.204949GIAMPAL@auvm.auvm.edu> GIAMPAL@auvm.auvm.edu writes:
>
>>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
I generally do this:
Say(s)
char *s;
{
return(Write(Output(), s, strlen(s)));
}
Or the equivalent, which takes much less room (in terms of code size).
Also, Write() and Output() take so much overhead that the difference in
execution speed of the subroutine, Say(), verses the SAY macro would
not be noticable.
builtins are generally useless and I sometimes wonder if Lattice added
them simply to optimize inefficiencies in their own source code.
-Matt
--
Matthew Dillon dillon@Overload.Berkeley.CA.US
891 Regal Rd. uunet.uu.net!overload!dillon
Berkeley, Ca. 94708
USA
Technical Details
Message-ID:
<dillon.7352@overload.Berkeley.CA.US>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!watserv1!watmath!att!linac!pacific.mps.ohio-state.edu!zaphod.mps.ohio-state.edu!wuarchive!uunet!overload!dillonReferences:
<dillon.7256@overload.Berkeley.CA.US> <90324.204949GIAMPAL@auvm.auvm.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watserv1!watmath!att!linac!pacific.mps.ohio-state.edu!zaphod.mps.ohio-state.edu!wuarchive!uunet!overload!dillon From: dillon@overload.Berkeley.CA.US (Matthew Dillon) Newsgroups: comp.sys.amiga.tech Subject: Re: C compilers code generation Message-ID: <dillon.7352@overload.Berkeley.CA.US> Date: 27 Nov 90 03:58:29 GMT References: <dillon.7256@overload.Berkeley.CA.US> <90324.204949GIAMPAL@auvm.auvm.edu> Lines: 48