From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2362 invoked by alias); 7 Jan 2013 15:30:08 -0000 Received: (qmail 2345 invoked by uid 22791); 7 Jan 2013 15:30:07 -0000 X-SWARE-Spam-Status: No, hits=-7.3 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,RP_MATCHES_RCVD,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 07 Jan 2013 15:30:01 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r07FU0RL018472 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 7 Jan 2013 10:30:01 -0500 Received: from zebedee.pink (ovpn-113-113.phx2.redhat.com [10.3.113.113]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r07FTxxq021473; Mon, 7 Jan 2013 10:30:00 -0500 Message-ID: <50EAE9F7.5040405@redhat.com> Date: Mon, 07 Jan 2013 15:35:00 -0000 From: Andrew Haley User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: horseriver CC: gcc-help@gcc.gnu.org Subject: Re: how to implement this ? References: <20130107044616.GD2432@debian.localdomain> <50EADC37.1010209@redhat.com> <20130107051145.GE2432@debian.localdomain> <50EAE52B.8000001@redhat.com> <20130107053935.GA26946@debian.localdomain> In-Reply-To: <20130107053935.GA26946@debian.localdomain> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2013-01/txt/msg00041.txt.bz2 On 01/07/2013 05:39 AM, horseriver wrote: > On Mon, Jan 07, 2013 at 03:09:31PM +0000, Andrew Haley wrote: >> On 01/07/2013 05:11 AM, horseriver wrote: >>> On Mon, Jan 07, 2013 at 02:31:19PM +0000, Andrew Haley wrote: >>>> On 01/07/2013 04:46 AM, horseriver wrote: >>>>> hi: >>>>> >>>>> how to implement this assignment by MACRO? >>>>> int a,b,c ; >>>>> >>>>> ((a==0)?b:c)=8; >>>> >>>> This is for help with GCC, not general C coding help. >>>> >>>> *((a==0) ? &b : &c) = 8; >>>> >>>> But this is really horrible code. I wouldn't do it. >>> >>> thans! >>> >>> why gcc report that error ? >>> >>> gcc can translate " ((a==0)?b:c)=8 " into if-else sentence . >>> >>> wht is the reason ? >> >> Please supply the test case and the error message. >> > > ok > > here is this code : > > #define INPUT_KEYCODE(dev, scancode) ((dev->keycodesize == 1) ? ((u8*)dev->keycode)[scancode] : \ > ((dev->keycodesize == 2) ? ((u16*)dev->keycode)[scancode] : (((u32*)dev->keycode)[scancode]))) > > and here is the callee code : > > unsigned int keycode ; > > INPUT_KEYCODE(dev, scancode) = keycode; > > dev is a struct , scancode is a unsigned int > > and gcc report error is : > > error: lvalue required as left operand of assignment That is the wrong error. I need to see the whole of the code that resulted in the error that was "gcc can translate " ((a==0)?b:c)=8 " into if-else sentence ."