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 ."