Article View: comp.sys.amiga.tech
Article #1911Re: Lattice 5.04 problem with free()
From: Tomas G. Rokicki
Date: Mon, 30 Oct 1989 22:32
Date: Mon, 30 Oct 1989 22:32
22 lines
1285 bytes
1285 bytes
carpent@SRC.Honeywell.COM (Todd Carpenter) 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) Well, imagine what happens when you try to SQR(a+b). You get a+b*a+b which doesn't parse as you intended. The solution is to change the macro definition to #define SQR(x) ((x)*(x)) In general, when defining expression macros, always surround each occurence of a parameter with a pair of parentheses, and surround the entire expression with another pair of parentheses, to make sure you get the precedences correct. -tom
Technical Details
Message-ID:
<12765@polya.Stanford.EDU>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!utstat!jarvis.csri.toronto.edu!mailrus!wuarchive!cs.utexas.edu!rice!uw-beaver!Teknowledge.COM!polya!rokickiReferences:
<36769@srcsip.UUCP> <37167@lll-winken.LLNL.GOV> <36899@srcsip.UUCP>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!utstat!jarvis.csri.toronto.edu!mailrus!wuarchive!cs.utexas.edu!rice!uw-beaver!Teknowledge.COM!polya!rokicki From: rokicki@polya.Stanford.EDU (Tomas G. Rokicki) Newsgroups: comp.sys.amiga.tech Subject: Re: Lattice 5.04 problem with free() Message-ID: <12765@polya.Stanford.EDU> Date: 30 Oct 89 22:32:55 GMT References: <36769@srcsip.UUCP> <37167@lll-winken.LLNL.GOV> <36899@srcsip.UUCP> Organization: Computer Science Department, Stanford University Lines: 22