Re: pointer indirection on the LHS of an assignment

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Robert P. J. Day wrote:

>   sort of a combination of a C and gcc question but what's the rules
> these days on the following (ripped from the linux kernel source, from
> asm/semaphore.h)?
> 
> ===
> static inline void sema_init (struct semaphore *sem, int val)
> {
> /*
>  *      *sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val);
>  *
>  * i'd rather use the more flexible initialization above, but sadly
>  * GCC 2.7.2.3 emits a bogus warning. EGCS doesn't. Oh well.
>  */
>         atomic_set(&sem->count, val);
>         sem->sleepers = 0;
>         init_waitqueue_head(&sem->wait);
> }
> ===
> 
>   i recall that earlier compilers complained about that first example
> of pointer indirection as the target of an assignment.  is that legal
> these days?

The problem with the first example is that the __SEMAPHORE_INITIALIZER
macro uses C99 features, which probably aren't supported in gcc 2.7.x.

The LHS has nothing to do with it.

-- 
Glynn Clements <glynn@xxxxxxxxxxxxxxxxxx>
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Assembler]     [Git]     [Kernel List]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [C Programming]     [Yosemite Campsites]     [Yosemite News]     [GCC Help]

  Powered by Linux