Re:15-line hash table in C
by viraptor on Thursday December 11, 2014 @11:53PM
(#8738619)
Is this some common style?
I've never seen parens used like that. Usually it's:
[ Parent
| on HN ]
Re:15-line hash table in C
by userbinator on Friday December 12, 2014 @12:53AM
(#8738765)
[] has higher precedence than *, so without the parens you get "function returning array of two pointer to pointer to int" (which is illegal) instead of the desired "function returning pointer to pointer to array of two int".
So would that be equal to this?
typedef int arr2int[2];
typedef arr2int** ptr_arr2int;
#define SIZE 1024
static ptr_arr2int hnew() {
return calloc(sizeof(int**), SIZE);
}parens are used since the [2] is on the end. Otherwise, it would think its a pointer to a pointer of an int [2] -> (hnew()[2]).
Might be to fix some -pedantic issue.