0

In my c application, I want to use Init_Message_Body() to return a message with default set of 0. But it always causes error: expression must be a modificable lvalue.

typedef union Msg_body_u
{
    uint8_t field[10][10];
} Msg_body;

Msg_body Init_Message_Body()
{
    Msg_body body;
    uint8_t msg_field[10][10] = {0};
    body.field = msg_field;           ===> expression must be a modifiable lvalue
    return body;
}

Why this error happens?

lei lei
  • 1,533
  • 3
  • 15
  • 36

0 Answers0