2 ms·
The syntax used in the following function definition is said to be obsolescent in C11: int f (a, n) int n; int a[n][n]; { return a[n-1][n-1]; } How could
by radford-neal 7y ago
The syntax used in the following function definition is said to be obsolescent in C11:
int f (a, n)
int n;
int a[n][n];
{ return a[n-1][n-1];
}
How could one define this function without using the obsolete syntax?
- AaronBallman 7y agoYou couldn't in that parameter order. However, you could do this: int f(size_t n, int a[n][n]) { return a[n-1][n-1]; } (https://godbolt.org/z/DV9c-C https://godbolt.org/z/DV9c-C) Btw, that definition was obsolescent in C89 too.
- radford-neal 7y agoWell, yes. But putting the array argument(s) first is the more natural order, in my opinion. And it is surely odd that only one order is allowed in this context, when otherwise C is happy with changing the order of parameters to be whatever you like. Plus, of course, there may be existing code using such functions, with parameters in the order that would become impossible if this syntax were disallowed.