C and pointer designation

Opening the Postgres code base, I see that most of the C code is written using pointers with the designation → in such a way that:

(foo)->next = 5;

I know that pointer designation has priority levels such as → = (* foo). and does not match * foo.

However, does this mean anything if the parentheses are outside the variable name and do not refer to the address of the next, or is it just a convention that is endemic to the coding style?

+5
source share
3 answers

This is an encoding convention that I have not seen before.

But it does not change anything.

(foo)->next = 5;

exactly equivalent

foo->next = 5;
+6
source

This is a coding convention for security.

, foo - , parens .

(foo)->next = 5;

, , foo , .

Parens , , . , :

( ++get_foo() )->next = 5;

:

( (db_record*)foo_ptr )->next = 5;

-, C, , , ; -)

+2

. , .

(*(foo)).next = 5;

, , . , , . , , , .

+1
source

All Articles