We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
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).
I may no sweeping statement, just reiterated ANSI/ISO C requirements. How the implementation actually returns a struct should not matter. The fact is the code works as if the structure was returned. That is, you don't need to return a pointer to the struct and you can still access the data of the returned struct (it doesn't dissappear when the function returns). I stand by ANSI C, the struct returned is returned as an object from the point of view of the code. How the compiler implements this facet of ANSI C is of no concern to me unless I'm worried about efficiency. Regards. - Mark