Defining a Macro to Return the Number of Elements in an Array
The storage size of a float[] would be unknown to the compiler.
I wonder if you're passing a statically allocated array into a function with a 'const float[]' arguement. If so, then, you're right - that macro would not work in the context of that function. The function could be getting an array of any size and the compiler wouldn't be able to resolve the size of the array in the context of the function.
Some options:
- Have that function reference the statically allocated array directly
- Add an array size parameter to the function arguement list
- Create (or re-use) a class that knows the size
- Create a template with a size