Hi Groepaz, >> I know that you cant return a struct by value. Is there any way around >> this? If I return a pointer to the struct, the values are lost upon >> leaving the function. Can anyone provide an example workaround? > 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) Maybe it's woth mentioning that your proposal presumes that memcpy() a) is inlined / is a specially designed intrinsic / <you name it> b) doesn't use the stack itself because otherwise calling it could overwrite the data you want to copy. From that perspective I'd rather classify this approach as hack than as workaround. Best, Oliver ---------------------------------------------------------------------- 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 11:31:08 2009
This archive was generated by hypermail 2.1.8 : 2009-08-10 11:31:11 CEST