Re: Multidimensional C arrays as OBJ-C method args: partial
Re: Multidimensional C arrays as OBJ-C method args: partial
- Subject: Re: Multidimensional C arrays as OBJ-C method args: partial
- From: Bob Savage <email@hidden>
- Date: Wed, 02 Jan 2002 18:58:02 -0600
Bill, thanks for taking the time to respond.
>
> // "passing arg 1 of
>
> 'setFloatValueByTotallingArrayPointer:ofSize:andStride:' from incompatible
>
> pointer type"
>
> //
>
> [aTester setFloatValueByTotalingArrayPointer:multidimensional ofSize:
>
> 4
>
> andStride:3 ];
>
>
The compiler warning is because the method declaration indicates that it
>
is taking a (float *), not a (float *)[] or a float[][].
>
Exactly! Using brackets while declaring the method like this:
-(void)setFloatValueByTotalingArrayPointer:(float *)theArray[];
(which is pretty much what I would do in plain ol' C) gives me an error:
"illegal method prototype, missing ';' after 'theArray'"
If this were a C function prototype one could even specify the sizes of the
arrays and that would give the called function the information to properly
report sizes with the sizeof operator. It is because the method doesn't have
that extra size information (which belongs between the brackets) that it
can't do the pointer arithmetic without help from the 'size' and 'stride'
arguments.
>
0xbffff6d8, 0xbffff6e0: 0xbffff6d8, 0xbffff6dc, 0xbffff6e0, 0xbffff6e4
>
>
Confused yet?
Always :)
>
I always liked libraries/classes that handled this stuff for me... :-)
Or languages... but in this case I want to be able to call OpenGL functions
which simply won't understand NSArrays.
Bob