From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25245 invoked by alias); 7 Jan 2013 15:21:48 -0000 Received: (qmail 25237 invoked by uid 22791); 7 Jan 2013 15:21:47 -0000 X-SWARE-Spam-Status: No, hits=-3.0 required=5.0 tests=AWL,BAYES_00,DATE_IN_PAST_06_12,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,KHOP_RCVD_TRUST,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org Received: from mail-pb0-f41.google.com (HELO mail-pb0-f41.google.com) (209.85.160.41) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 07 Jan 2013 15:21:41 +0000 Received: by mail-pb0-f41.google.com with SMTP id xa7so10728245pbc.28 for ; Mon, 07 Jan 2013 07:21:40 -0800 (PST) X-Received: by 10.66.84.3 with SMTP id u3mr177824907pay.51.1357572100910; Mon, 07 Jan 2013 07:21:40 -0800 (PST) Received: from localhost ([118.186.82.6]) by mx.google.com with ESMTPS id o11sm37810818pby.8.2013.01.07.07.21.37 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 07 Jan 2013 07:21:39 -0800 (PST) Date: Mon, 07 Jan 2013 15:25:00 -0000 From: horseriver To: Andrew Haley Cc: gcc-help@gcc.gnu.org Subject: Re: how to implement this ? Message-ID: <20130107053935.GA26946@debian.localdomain> References: <20130107044616.GD2432@debian.localdomain> <50EADC37.1010209@redhat.com> <20130107051145.GE2432@debian.localdomain> <50EAE52B.8000001@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <50EAE52B.8000001@redhat.com> User-Agent: Mutt/1.5.20 (2009-06-14) 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/msg00039.txt.bz2 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 thanks! > Andrew. > >