3 ms·
https://port70.net/~nsz/c/c11/n1570.html#6.7.6.3p7 https://port70.net/~nsz/c/c11/n1570.html#6.7.6.3p7 "A declaration of a parameter as ''array of type'' shall
by CodeArtisan 8y ago
https://port70.net/~nsz/c/c11/n1570.html#6.7.6.3p7 https://port70.net/~nsz/c/c11/n1570.html#6.7.6.3p7
"A declaration of a parameter as ''array of type'' shall be adjusted to ''qualified pointer to type'', where the type qualifiers (if any) are those specified within the [ and ] of the array type derivation. If the keyword static also appears within the [ and ] of the array type derivation, then for each call to the function, the value of the corresponding actual argument shall provide access to the first element of an array with at least as many elements as specified by the size expression."
According to this, the following syntax could be used for optimization
void foo(size_t n, int array[static n]) {...}
pointers to array could be used too
void foo(size_t n, int (*array)[n])
{
printf("array %zu, *array %zu\n", sizeof(array), sizeof(*array));
}
foo( 10, null); // array 8, *array 40
foo(100, null); // array 8, *array 400