-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Robert said:
Rich said:
[....]
Nonsense. It's trivially easy to pass and return structures - the only
limit is your stack size:
Yes you are right, it works on gcc. Some years back I tried it on quite a
different C compiler and it choked. Is this a case of a bad compiler or
is it something added in, lets say, the last 7 years.
BTW: Can this be done with an array?
Dang! I don't know! How do you declare the function whose return value is
an array?
int[] foo(int[]); // ?
You have to hard-code the size, I think - or maybe union it onto a
structure? Then you'd still have to have a fixed size.
Probably not. Anybody want to try?
It has always been possible to return structures in C.
Sorry, but you are mistaken.
"There are a number of restrictions on C structures. The essential rules are
that the only operations that you can perform on a structure are take its
address with &, and access one of its memebers. This implies that structures
may not be assigned to or copied as a unit, and that they can not be passed
===============
to or returned from functions."
=======================
The C Programming Language
Brian W. Kernighan * Dennis M. Ritchie
Copyright (c) 1978 by Bell Telephone Laboratories, Incorporated
It has been possible to pass and return _pointers to structures_ in C, but
only recent standards (i.e. 89 and after) permitted passing and returning
actual structures.
[snip]
HTH
- --
Lew Pitcher
Master Codewright & JOAT-in-training | GPG public key available on request
Registered Linux User #112576 (
http://counter.li.org/)
Slackware - Because I know what I'm doing.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
iD8DBQFEPu5SagVFX4UWr64RAnGiAKCdgETkkIeNzxP5Tv9eRMVoNMNDrACfZsgX
4mJdM+L09jlZnyitjMNHahw=
=ZtRY
-----END PGP SIGNATURE-----