Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!crdgw1!camelback!volpe From: volpe@camelback.crd.ge.com (Christopher R Volpe) Newsgroups: comp.lang.c Subject: Re: Problem with #define'd macro... Message-ID: <18200@crdgw1.crd.ge.com> Date: 3 Apr 91 16:28:52 GMT References: <1991Mar20.150301.9941@evax.arl.utexas.edu> <1099@gtenmc.UUCP> <10868@ncar.ucar.edu> <18146@crdgw1.crd.ge.com> Sender: news@crdgw1.crd.ge.com Reply-To: volpe@camelback.crd.ge.com (Christopher R Volpe) Lines: 36 In article <18146@crdgw1.crd.ge.com>, volpe@camelback.crd.ge.com (Christopher R Volpe) writes: |>In article <10868@ncar.ucar.edu>, steve@groucho.ucar.edu (Steve |>Emmerson) writes: |>|>In <1099@gtenmc.UUCP> ravim@gtenmc.UUCP (Vox Populi) writes: |>|> |>|>>In article <1991Mar20.150301.9941@evax.arl.utexas.edu> |>c145gmk@utarlg.uta.edu |>|>writes: |>|>>>Attempting to compile the following (fragment, but displays the problem) |>|>>>results in an 'invalid target for assignment' error on our VAX running |>|> |>|>>>#define DIV_MOD(d,r,x,y) ( y == 0.0 ? d = 0.0, r = x : d = x/y, r = |>x - d*y ) |> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |> This is the root of the |> precedence problem because the value "x/y" is |> being assigned to the result of the conditional |> operator, which is not an lvalue, and therefore |> an illegal target for assignment. Steve Emmerson pointed out to me that the above expression is perfectly legal because the grammar in both K&R1 and K&R2 prevent parsing the ?: operator as the lhs of the assignment, thus precedence doesn't apply. (I put too much faith in Table 2.1). BTW, both GCC and SunOS cc get this completely wrong. They complain about invalid lhs of assignment. Thanks, Steve. -Chris ================== Chris Volpe G.E. Corporate R&D volpecr@crd.ge.com