That's not a style I would be encouraging to use today
It also uses sizeof to calculate the size of an array which would be good in any language except C
That's not a style I would be encouraging to use today
It also uses sizeof to calculate the size of an array which would be good in any language except C
Having function return types on an extra line is actually quite useful, because you can easily grep for the function implementation with `grep ^foo -r .`
This works quite well, even on huge code bases.
FreeBSD maintains this style, so you can just 'git grep ^function' to find a function's definition.
When working with other codebases which don't follow this convention, its somewhat frustrating to find a function's definition with just grep.
static inline const unsigned int *
function()Or:
You can use ctags (like the Linux kernel)
or just grep for something like (egrep) '^[a-z]+ .+foo\(' if you're really bothered by grepping function calls instead of only definitions
It is a pretty standard and popular way of finding the size on an array. The only caveat is that the programmer really has to be sure that it really is an array and not a pointer to an array.
Many other languages however don't have the equivalent of the sizeof operator because they don't expose an object's memory representation quite as much as C does.
int * my_array;
my_array = malloc(100*sizeof(int));
int array_length = sizeof(my_array);It also works for variable length arrays.
void f(int n)
{
float a[n];
int m = sizeof a / sizeof *a;
assert(n == m);
}Shame on them for not promoting your personal taste in coding style.