how do i debug error: lvalue required as left operand of assignment?

后端 未结 4 1463
既然无缘
既然无缘 2021-01-20 04:50

I\'m compiling a .c program using gcc compiler on linux,

But , i received the error shown as \"error: lvalue required as left operand of assignment\"

The er

相关标签:
4条回答
  • 2021-01-20 05:25

    Your code is nonsensical. Try

    saddr_size = (int)(*data2.ssize);
    

    But ... why is saddr_size declared int? Try

    socklen_t saddr_size;
    ...
    saddr_size = *data2.ssize;
    

    I also wonder why ssize is a pointer, rather that the size itself.

    0 讨论(0)
  • 2021-01-20 05:26

    try changing it like

    *(socklen_t*)&saddr_size=*(data2.ssize)

    0 讨论(0)
  • 2021-01-20 05:41

    In C, an lvalue is a "left" value, which means a token to which it is valid to assign a value. So the compiler is telling you that the token on the left side of an assignment expression is not valid.

    0 讨论(0)
  • 2021-01-20 05:44

    The left value you have cast it to a socklen_t * pointer type, however the right value is socklen_t type, so this error is printed. I have the same question as Jim Balter, you should make sure the socklen_t type can be expressed by int. I mean if int is 32 bytes, would socklen_t be more than 32 bytes? You should declare saddr_size socklen_t type

    0 讨论(0)
提交回复
热议问题