This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

c2000: struct literals as function arguments



For the following code

struct abc_struct {
  unsigned a:2;
  unsigned b:2;
  unsigned c:12;
};

unsigned bar(struct abc_struct s)
{
  return s.c;
}

unsigned foo(void)
{
  return bar((struct abc_struct) {2, 2, 42});
}

I get the error messages (with cgtools 5.2.10 and 6.0.2):

"con_init.c", line 1531: error #120: cast to type "struct abc_struct" is not
          allowed
    return bar((struct abc_struct) {2, 2, 42});
                ^

"con_init.c", line 1531: error #29: expected an expression
    return bar((struct abc_struct) {2, 2, 42});
                                   ^

Is this behaviour to be expected?

Thanks, Johannes