@schmee it is indeed a good thing to specify the variable if possible instead of the type. The C compiler will automatically fill in the size of the type that the variable has. This is very good for maintainability and prevents bugs: changing the type of the variable will adjust all allocations of it as well.

There is, however, something you have to be really careful about: the difference between arrays and pointers. Even though one usually "handles" arrays and pointers in the same way, they react differently to `sizeof`:

```c
/**
 * cc -Wall -pedantic sizeof.c -o sizeof
 */
#include <stdio.h>
#include <string.h>
#include <inttypes.h>

#define NELEMS(x)  (sizeof(x) / sizeof(x[0]))

int main() {
    int arr[64];
    int *parr;

    printf("sizeof(int) = %zu\n", sizeof(int));
    printf("sizeof(uint32_t) = %zu\n", sizeof(uint32_t));
    printf("sizeof(size_t) = %zu\n", sizeof(size_t));

    printf("sizeof(arr[64]) = %zu (NELEMS = %zu)\n", sizeof(arr), NELEMS(arr));
    printf("sizeof(int *) = %zu\n", sizeof(parr));

    return 0;
}
```

output:

```
sizeof(int) = 4
sizeof(uint32_t) = 4
sizeof(size_t) = 8
sizeof(arr[64]) = 256 (NELEMS = 64)
sizeof(int *) = 8
```

The `NELEMS` macro relies on this behaviour. This is possible because the compiler is guaranteed to know the size of the array at compile time. So pay attention to that.

On a separate note, there is a slightly safer alternative to the `NELEMS` macro that we perhaps should consider: https://groups.google.com/forum/#!topic/comp.std.c/IsJaXEhtgIQ