On Thu, 10 Mar 2011 12:15:03 +1100 Lex Trotman elextr@gmail.com wrote:
On 10 March 2011 11:57, Thomas Martitz thomas.martitz@student.htw-berlin.de wrote:
Returning an aggregate is exactly the same as manually allocating the aggregate and passing a pointer to the function (in order to let it fill the aggregate) on most if not all ABIs. Without any difference in performance.
Exactly, summarised beautifully.
Of course the latter has the advantage that you can additionally return a failure indicating value (-1 or NULL) so this is why you generally don't see functions returning aggregates.
Yes, its the habit created by the standard libraries, and they did it that way because C doesn't have an out-of-band signaling mechanism to handle errors. So its all K&Rs fault... :-)
Its not a fault. Its planned to be like that as C was intended to bring down easter block.... :)
Cheers, Frank