Unspecified Bounds Error When an Array is Passed to a Macro
I attempted to use this macro:
Copy to clipboard
#define ARSIZE(AR) (((char *)(&AR+1) - (char *)(&AR))/( (char *)(&AR[1]) - (char *)(&AR[0]) ))
in code such as this:
Copy to clipboard
int array[] = {1,2,3,4,5}; size_t N = ARSIZE(array);
The compiler outputs the error:
Copy to clipboard
invalid use of array with unspecified bounds
on the attempt to expand the macro in the last line above.
My expectation was the compiler would simply plug in the text "array" where the AR argument is in the macro definition and compile the code. What I find instead is the same error as if the array were attempted to be passed to any function this way.
How can an array be passed to this macro?
