可能重复: C/C++宏中的Do-while和if-else语句
我正在阅读linux内核,我发现了很多像这样的宏:
#define INIT_LIST_HEAD(ptr) do { \ (ptr)->next = (ptr); (ptr)->prev = (ptr); \ } while (0)
为什么他们使用这个而不是简单地在{}中定义它?
c macros linux-kernel
c ×1
linux-kernel ×1
macros ×1