This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Problem with structs as return values

I am using functions, which returns structs. This shouldn't
be a problem in C. And it works mostly.
But are there contexts where this is not
allowed? Maybe there a conflicts because
those structs are returned by using registers?

for example:

typedef struct {

unsigned char Byte_1;
unsigned char Byte_2;
} two_byz;

two_byz f_a(void)
{
two_byz rueck;
rueck.Byte_1 = 0xAA;
rueck.Byte_2 = 0xBB;
return ( rueck);
}


two_byz test;

test = f_a();

Again: this example does work - mostly!
But as
i used this module in another program
there was just no return value.
It is really weird, the function then
behaves like void f_a(void).

Parents
  • In fact there was no problem with
    the function or the function calling.

    In this other modul, which i've
    mentioned, i had produced a great
    memory overflow. I admitt this was a
    really silly mistake.

    However, I thank you for your trouble
    and by the way it was useful information.

Reply
  • In fact there was no problem with
    the function or the function calling.

    In this other modul, which i've
    mentioned, i had produced a great
    memory overflow. I admitt this was a
    really silly mistake.

    However, I thank you for your trouble
    and by the way it was useful information.

Children
No data