Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!mit-eddie!genrad!decvax!decwrl!amdcad!amd!pesnta!peora!ucf-cs!novavax!hcx1!notes From: notes@hcx1.UUCP Newsgroups: comp.lang.c Subject: structure function returns -- how? Message-ID: <131@hcx1.UUCP> Date: Fri, 5-Dec-86 08:55:26 EST Article-I.D.: hcx1.131 Posted: Fri Dec 5 08:55:26 1986 Date-Received: Sun, 7-Dec-86 03:34:47 EST Sender: notes@hcx1.UUCP Organization: Harris CSD, Fort Lauderdale, Florida Lines: 21 Nf-ID: #N:hcx1:44100002:000:896 Nf-From: hcx1!daver Dec 5 07:08:00 1986 Suppose a is declared as a structure and b is a function which returns a structure. In the statement: a = b () ; when and how should the copying into a take place? The pcc compilers I have seen apparently "set" b in b's stack frame. They then return a pointer to b in that frame, and copying from that pointer is done in a's frame. But what happens if a signal comes through during the copy? The contents of b , which are not yet copied, are overwritten by the signal routine's stack frame? Another compiler overcomes this problem by passing the address of a local structure in a's frame to the function b . Thus, instead of "setting" b , a's local structure is filled up, and copying from that local structure occurs when b returns. Are there other issues to be considered? Dave Ray -- uucp: {ucf-cs|allegra}!novavax!hcx1!daver