Re: [cc65] returning structs

From: Scott Hutter <scott.hutter1gmail.com>
Date: 2009-08-10 04:45:43
Well, its not as pretty as returning a struct by value, but here's something
of what I did:  I created a struct in the main function, then sent it into
another function by reference (pointer).  Made the changes inside the
function, which of course then were available back in the main function.

Id like to see an example though of what you're refering to though.  If Im
reading you right, it seems that when you return from the called function,
the data would be lost since the called function's struct is local to that
function.

On Sun, Aug 9, 2009 at 9:24 PM, Groepaz <groepaz@gmx.net> wrote:

>
> make it return a pointer, and then copy it to a local struct:
>
> memcpy(&localstruct,functhatreturnsstruct(),sizeof(localstruct));
>
> (thats pretty much almost exactly what a compiler would do too)
>
>

----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Mon Aug 10 04:45:52 2009

This archive was generated by hypermail 2.1.8 : 2009-08-10 04:45:54 CEST