Document directory
Do... while (0)-usage (transfer ...)
Reprinted from: http://blog.ednchina.com/fpga2006/34658/message.aspx
# Define macro_name (para) do {macro content} while (0)
The following reasons are summarized:
1. Empty macro
Benefits of using do {} while (0) in macro definition (reprinted), dowhileBenefits of using do {} while (0) in macro definition
#define MACRO_NAME(para) do{macro content}while(0)The following reasons are summarized: 1. the empty macro definition
Benefits of using do {} while (0) in macro definition
#define MACRO_NAME(para) do{macro content}while(0)The following reasons are summarized: 1. the empty macro definition avoids warning: # define foo () do {} while (0) 2. An independent block
Benefits of using Do{}while (0) in macro definitions#define MACRO_NAME (para) Do{macro content}while (0)Format, summed up the following reasons: 1, empty macro definition to avoid warning: #define FOO () do{}while (0) 2, there is a separate block,
How to do while (0) in Linux kernel using C language
Why do while (0? Because it is indeed wonderful, and the implementation in the Linux kernel is quite good, let's look at the relevant code in the kernel:
#define db_error(fmt, ...) \ do { \
In C ++, there are three types of loop statements: For, while, and do... while, but in general applications for loop, we may use for and while to have more, do... while is relatively not valued.However, when I recently read the code of our project,
# Define macro_name (para) do {macro content} while (0)The following reasons are summarized: 1. the empty macro definition avoids warning: # define Foo () do {} while (0) 2. An independent block exists, it can be used to define variables for
Welcome reprint, Reproduced please specify the original address: http://blog.csdn.net/majianfei1023/article/details/452468650. GuidanceThe first time I saw do{...} while (0) is when learning libevent, see there are many similar#define Tt_uri (Want)
# Define macro_name (para) do {macro content} while (0) format summarizes the following reasons: 1. Empty macro definition avoids warning:
# Define Foo () do {} while (0) 2, which has an independent block that can be used for variable definition and
If you are a C programmer, you must be familiar with macros, they are very powerful, if used correctly can make your work more effective. Then, if you're defining macros and you're not checking them out at random, then they can make you mad and
Linux Kernel and some other open-source code often encounter such code:
do{ ...}while(0)
Such code is not a loop at first glance. Do... while has no meaning at all on the surface, so why should we use it like this?
In fact, do {...}
The Linux kernel and some other open source code often encounter such code: Do { ...} while (0)This code is not a loop at a glance, do. While the surface is meaningless here, why use it so much?In fact, do{...} while (0) is much more useful than
The Linux kernel and some other open source code often encounter such code:
Do{...} while (0)
This code is not a loop at a glance, do. While the surface is meaningless here, why use it so much?In fact, do{...} while (0) is
The Linux kernel and some other open source code often encounter such code:Do{...} while (0)This code is not a loop at a glance, do. While the surface is meaningless here, why use it so much? In fact, do{...} while (0) is much more useful than
From: http://blogread.cn/it/article/5907
Linux Kernel and some other open-source code often encounter such code:
do{ ...}while(0)
Such code is not a loop at first glance. Do... while has no meaning at all on the surface, so why should
You is a C programmer, you must is familiar with macros. They is powerful and can help you ease your work if used correctly. However, if you don ' t define macros carefully, they could bite you and drive you crazy. In the many C programs, you could
do{...} The meaning and usage of while (0)On October 9, +, in C language, language learning, by sponge
The Linux kernel and some other open source code often encounter such code:
do{...
} while (0)
This code is not a loop at a glance, do. While the
In C ++, there are three types of loop statements: For, while, and do... while, but in general applications for loop, we may use for and while to have more, do... while is relatively not valued.However, when I recently read the code of our project,
Why does while (0) wonderful? Because it's really good, and it's pretty good to implement in the Linux kernel, let's look at the relevant code in the kernel:#define DB_ERROR (FMT, ...) do { fprintf (stderr, "(Error):"); fprintf (stderr, FMT, #
Why does while (0) wonderful? Since it's really good, and it's pretty good to implement in the Linux kernel, let's look at the relevant code in the kernel:#define DB_ERROR (FMT, ...) do { fprintf (stderr, "(Error):"); fprintf (stderr, FMT, # #
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.