parenthesis while addressing struct member
Carlos O'Donell
carlos@systemhalted.org
Sat Jul 26 17:19:00 GMT 2014
On Sat, Jul 26, 2014 at 11:13 AM, Joël Krähemann <weedlight@gmail.com> wrote:
> I experienced problems as not using parenthesis with addressing operator.
> Does someone know what's correct?
>
> pthread_mutex_lock.c
>
> int e = INTERNAL_SYSCALL (futex, __err, 4,
> &mutex->__data.__lock,
> __lll_private_flag (FUTEX_LOCK_PI,
> private), 1, 0);
>
> ags_thread-posix.c
>
> pthread_mutex_init(&(thread->timelock_mutex), NULL);
They are both the same.
The -> and . have precedence over & with left-to-right associativity.
Therefore &(struct->member) is equivalent to &struct->member.
Only () can change this e.g. *(ptr[x]) is not equivalent (*ptr)[x].
Cheers,
Carlos.
More information about the Libc-help
mailing list