4 ms·
ARRAY_PARAM (as I assume you mean?) has no problem with two arrays. You just give them different names. Suppose you do this: void CopyIntArray(ARRAY_PARAMS
by to3m 10y ago
ARRAY_PARAM (as I assume you mean?) has no problem with two arrays. You just give them different names. Suppose you do this:
void CopyIntArray(ARRAY_PARAMS(int,*dest),ARRAY_PARAMS(int,src))
Now you end up with this:
void CopyIntArray(int **dest,size_t *dest_length,size_t *dest_capacity,
int *src,size_t src_length,size_t src_capacity);
And you can call it like this:
ARRAY(int,xs);
ARRAY(int,ys);
CopyIntArray(ARRAY_ARG(&xs),ARRAY_ARG(ys))
Your point about token pasting with * p is a very good one, and I don't think that had occurred to me... but neither clang, gcc or VC++ seems to mind (and I used a number of different versions of each). I need to go and look up what the C standard has to say about this now.
I do note that I didn't use ARRAY_PARAM or ARRAY_ARG all that much in my code, though - but I don't remember whether this is because I found some problem with them in practice, or whether it just ended up that way.
(I'm on OS X right now and I just tried my code with clang. Probably-relevant compile flags were "-std=c1x -Wall -Wuninitialized -Winit-self -pedantic -Werror=implicit-function-declaration -Wsign-conversion -Wunused-result -Werror=incompatible-pointer-types -Werror=int-conversion -Werror=return-type -Wno-overlength-strings -Wunused-parameter".)
- tines 10y agoAh good catch, I misread it.