#define ... do { ... } while(0) : a corner case

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

 



Hi,

The do{SOMETHING}while(0) thingy has been often discussed in
many mailing lists, and recently an entry about it was 
updated in kernelnewbies FAQ.

However, what's the role of do{SOMETHING}while, if that 
SOMETHING is empty. In kernel, both forms of defining 
'empty' function-like macros are used:

#define foo(stuff...)	do { } while(0)

and

#define foo(stuff...)

Purely a style difference, or something more there? If just 
a style thing, why would anyone prefer a style, which gives 
(slightly) more work to compiler?

Thanks in advance,
Olav

PS. Please keep me CC-d as I am not subscribed.

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux