When should we use a size with or without brackets


This question already has an answer here:

  • What does sizeof without () do? [duplicate] 5 answers
typedef struct rem{
    int  addr;
    char addrbuf[32];
} foo;

Both of these codes return the same results

foo addr;
printf("size is: %d\n",sizeof addr);
printf("size is: %d\n",sizeof (foo));

size is: 36

size is: 36

But when should we use sizeof with and without parentheses?

When using sizeof with a type, you need parentheses around the type. When using it with an expression, you don't. But you can of course include them in this case as well, and you don't have to worry about operator precedence in such case. With uncommon operators such as this one, fewer people would be sure of the precedence, so clarity certainly helps.

So I'd say it's preferable to use them always.