Mailing List Archive

Support open source code!


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

Re: tlug: GCC compiler question



Hello,

> >If we were to declare the macro as follows:
> >
> >#define spin_lock_init(x)       { (x)->lock = 0; }
> >
> >Then this would expand to  
> >
> >if (true)
> >   { (x)->lock = 0; }
> 
> Wouldn't it expand to this?
> 
>   if (true)
>      { (x)->lock = 0; };

Very true. The above would expand to:

   if (true)
      { (x)->lock = 0; };

Which causes 2 problems I can think of. One is that it introduces a 
redundant statement, and the other is that it can cause compile
errors depending on the context of the statement. 

Consider:

if (true)
   { (x)->lock = 0; };
else 
   do_something_else ();

Regards,

Peter
--
      Peter Linsley
      Oracle Corporation Japan
             
---------------------------------------------------------------
Next Nomikai: 20 November, 19:30 Tengu TokyoEkiMae 03-3275-3691
Next Meeting: 12 December, 12:30 Tokyo Station Yaesu central gate
---------------------------------------------------------------
Sponsor: PHT, makers of TurboLinux http://www.pht.co.jp


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links