cmacroslvaluemikroc

why does the 2nd statement creates Assigning to non-lvalue '' main.c?


hi whats the difference between these statements given below?

 #define RES_WRITE 0Xf0f0
 #define DATA (0x0000 |= (1<<15))
 #define DATA (RES_WRITE |= (1<<15))

when DATA is assigned to a int variable it shows an error like "Assigning to non-lvalue. may i know the reason behind this error and how to resolve the error what mistake i am doing?


Solution

  • I think you want to send 0b1000000000000000 to a port of a microcontroller or globally to a buffer. change |= to |

    why you faced error?

    consider one of your macros:

    #define DATA (0x0000 |= (1<<15))
    

    in this macro, you try to do this:

    0x0000 = 0x0000 | (1<<15))
    

    is it possible to write data on 0x0000? 0x0000 is value; it means that it don't have any location on memory.