Re: reason for code like this: "do { something } while (0)" | |
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] | |
On 15/05/06, Rajat Jain <rajat.noida.india@xxxxxxxxx> wrote:
Hi,
I'm asking a pretty amateur question.
I've come accross code like this huge number of times in the kernel:
#define __set_task_state(tsk, state_value) \
do { (tsk)->state = (state_value); } while (0)
What is the reason to use do while loop if it is only meant to be
executed just once? Why not a simple:
#define __set_task_state(tsk, state_value) \
{ (tsk)->state = (state_value); }
http://www.kernelnewbies.org/FAQ/DoWhile0 -- Jesper Juhl <jesper.juhl@xxxxxxxxx> Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html Plain text mails only, please http://www.expita.com/nomime.html - To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.linux-learn.org/faqs
[Site Home] [Audio] [Hams] [Kernel Newbies] [Memory] [Security] [Netfilter] [Bugtraq] [Writing Drivers] [Photo] [Yosemite Photos] [Yosemite News] [MIPS Linux] [ARM Linux] [Linux Security] [Linux RAID] [Samba] [Video 4 Linux] [Linux Resources] [Fedora Users]
![]() |