nick at ccl4.org
Fri May 11 13:51:40 BST 2007
On Fri, May 11, 2007 at 01:32:55PM +0100, Peter Corlett wrote:
> On Fri, May 11, 2007 at 12:58:03PM +0100, Jon Nangle wrote:
> > On Fri, May 11, 2007 at 12:37:57PM +0100, Peter Corlett wrote:
> >> By value rather than by reference. It's fairly rare in C, but common
> >> enough in C++.
> > What's the syntax to pass an array by value in C? I can't see any way to
> > do it.
> I've just given it a spin and looked at the assembler output, and I can't
> cause array pass-by-value either unless I wrap it in a struct. So it does
> seem that arrays do indeed turn into pointers. My memory of this is clearly
> faulty, presumably corroded by me normally wrapping them in classes and
> passing them that way.
IIRC (and I may not well enough) there does start to be a difference once
you get beyond the first dimension - functions that take arrays to arrays
aren't quite the same thing as functions that take pointers to pointers.
(You have to provide fixed dimensions on all but the outermost array, because
implementation-wise maths is done relative to a single pointer, rather than
making n levels of pointer direction)
(and don't expect me to remember which end is innermost. Although it is the
opposite direction from the F word)
More information about the london.pm