ALL
Significance and use of do{...}while(0)
In some Linux kernel and other open source codes, we can see some codes like below:do{ ...}while(0)This code snippet is not a loop, it seems there is no significance of using do...while this way, then why should we use it?In fact, the significance of do{...}while(0) is better than optimizing your code. After some research, we summarize some benefits of it.1. Help define complex macro to avoid error#define DOSOMETHING()\ foo1();\ foo2();The meaning of the macro is when calling DOSOMETHING(), the functions foo1() and foo2() will be called. But if you write it like thi...
10,627 0 DO{...}WHILE(0) OPTIMIZATION