Article View: comp.sys.amiga.tech
Article #1942Re: Lattice 5.04 problem with free()
From: Terry Fisher
Date: Wed, 01 Nov 1989 15:27
Date: Wed, 01 Nov 1989 15:27
28 lines
1518 bytes
1518 bytes
In article <GILHAM.89Oct31100813@cassius.csl.sri.com> gilham@csl.sri.com (Fred Gilham) writes:
>
>| As long as we are on the subject of Lattice, why doesn't this macro seem to
>| work? (I'm rather new to macrodom, so this is probably a silly one) I
>| have some terribly long nasty expressions that need to be squared, and
>| SQR(moocow) never returns what I expect:
>|
>| #define SQR(x) (x*x)
>|
>
>probably because moocow gets evaluated twice, which I bet is not what
>you want!
The fact that the expression gets evaluated twice is only an optimization
problem. The macro should be changed to
#define SQR( x ) ((x) * (x) )
Consider the line SQR( 2+3 ).
#define SQR( x ) (x * x ) causes the above to be substitued with
2+3*2+3 = 11
#define SQR( x ) ((x) * (x)) yields the expression
(2+3)*(2+3) = 25 as desired.
>-Fred Gilham gilham@csl.sri.com
Terry Fisher thfisher@lion.uwaterloo.ca
thfisher@lion.waterloo.edu
{...}!watmath!lion!thfisher
Technical Details
Message-ID:
<17724@watdragon.waterloo.edu>Path:
arc1-ca.pugleaf.net!utzoo!attcan!utgpu!watmath!watdragon!lion!thfisherReferences:
<36769@srcsip.UUCP> <37167@lll-winken.LLNL.GOV> <36899@srcsip.UUCP> <GILHAM.89Oct31100813@cassius.csl.sri.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!watmath!watdragon!lion!thfisher From: thfisher@lion.waterloo.edu (Terry Fisher) Newsgroups: comp.sys.amiga.tech Subject: Re: Lattice 5.04 problem with free() Message-ID: <17724@watdragon.waterloo.edu> Date: 1 Nov 89 15:27:50 GMT References: <36769@srcsip.UUCP> <37167@lll-winken.LLNL.GOV> <36899@srcsip.UUCP> <GILHAM.89Oct31100813@cassius.csl.sri.com> Sender: daemon@watdragon.waterloo.edu Reply-To: thfisher@lion.waterloo.edu (Terry Fisher) Organization: U. of Waterloo, Ontario Lines: 28