Mailing List ArchiveSupport open source code!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]tlug: GCC compiler question
- To: tlug@example.com
- Subject: tlug: GCC compiler question
- From: Neil Booth <NeilB@example.com>
- Date: Sat, 17 Oct 1998 22:52:48 +0900
- Content-Transfer-Encoding: 7bit
- Content-Type: text/plain; charset=us-ascii
- Organization: ...
- Reply-To: tlug@example.com
- Sender: owner-tlug@example.com
I've been looking through some of the kernel source, and I keep seeing things like the following:- #define spin_lock_init(x) do { (x)->lock = 0; } while(0) What's the point of the do {} while(0) bit? Why not just #define spin_lock_init(x) { (x)->lock = 0; } or even #define spin_lock_init(x) (x)->lock = 0; The only point I can see is causing compile-time errors for misuse, such as z += spin_lock_init(x); which would compile under the 3rd alternative above. And who would really write such code anyway? And why not the 2nd alternative? Neil. --------------------------------------------------------------- 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
- Follow-Ups:
- Re: tlug: GCC compiler question
- From: Peter Linsley <plinsley@example.com>
Home | Main Index | Thread Index
- Prev by Date: Re: tlug: Re: mem=size??? (plus lilo note)
- Next by Date: tlug: DIP switch SCSI ID
- Prev by thread: Re: tlug: Re: mem=size??? (plus lilo note)
- Next by thread: Re: tlug: GCC compiler question
- Index(es):
Home Page Mailing List Linux and Japan TLUG Members Links