Path: 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> Sender: daemon@watdragon.waterloo.edu Reply-To: thfisher@lion.waterloo.edu (Terry Fisher) Organization: U. of Waterloo, Ontario Lines: 28 In article 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