while 0

Learn about while 0, we have the largest and most updated while 0 information on alibabacloud.com

Do {} while (0) in the kernel)

Why are there so many do {} while (0) Macros in the kernel? I don't understand it at first. It doesn't seem to work. But after understanding it, you will know its benefits. The benefit lies in the macros of multiple statements. # Define Foo (x)

The magical do{}while (0)

Author: cpoint Source: http://www.cnblogs.com/cpoint/ In the Linux kernel code, often see Do...while (0) of the macro, Do...while (0) has a lot of effect, the following list of several: 1, avoid goto statement: Typically, if a function starts to

The magical application of Do...while (0) in C language-Avoid Goto

Use goto elegance and avoid structural confusionThe statement you want to jump to with do{...} while (0) you can wrap it up.Reference #defien N BOOLExecute () {//Allocate resources int*p = (int*)mallocNsizeof(int));BOOLBOk =true;//Run and error

Linux kernel:the "Do {...} while (0) "Magic

Read the Linux source when you see a bunch of these macro:#define FOO (x) does {f (x); g (x);} while (0)I've been trying not to understand why not use it directly#define FOO (x) f (x); g (x);Or:#define FOO (x) {f (x); g (x);}Search for a moment to

The clever use of do... while (0) in C language-avoid goto

The clever use of do... while (0) in C language-avoid goto Use goto elegance and avoid structure confusionUse do {…} to jump to the statement {...} Pack while (0.Reference # Defien N 10 bool Execute () {// allocate resource int * p = (int *) malloc (

Do {...} Clever Use of while (0)

In the Linux KernelCodeHas such macro definition:# Define dump_write (ADDR, NR) do {memcpy (bufp, ADDR, NR); bufg + = nR;} while (0) This macro definition means that the loop body will be executed once when this macro operation is referenced, but

# Define x do {...} while (0) Usage

For example, define macro, # define free1 (p) if (p) Free (P)Then, call:If (expression)Free1 (P );ElsePrintf ("expression was false. \ n ");Expand:If (expression)If (p) Free (P );ElsePrintf ("expression was false. \ n ");Let's see if else matches

Usage of do-while (0) and multibytetowidechar and widechartomultibyte

Requirement: When the font is displayed on the screen, if there are too many characters to be displayed by branch (divided into two lines), the first line and the second line each account for half of the characters. Because the displayed string is

Cocos2d-x problem set.

1. do {} while (0) in the source code) Write a code today: if(!CCScene::init()){return false;}Later I went to the source code: bool CCScene::init(){ bool bRet = false; do { CCDirector * pDirector; CC_BREAK_IF( !

Akagi201 code style

Akagi201 code style 1. application code and driver kernel code styles should be consistent as much as possible 2. The project directory name and file name can be underlined in lower case, without-connection, because the variable name in the source

Reasonable or illegal

From some classic Code Is often seen in the macro Do... while (0) Usage, feeling Do... while (0) It is replaced only when it is possible to jump out of a subsequent code section. Goto In other ways, the rest will not solve the problem. I

Test the Direct Screen Writing speed of vga12h

File: vgaspeed.txtName: test the speed of the vga12h ModeAuthor: zyl910Blog: http://blog.csdn.net/zyl910/Version: V1.0Updata: 2006-11-14 Download (note the modified extension) Introduction~~~~I 've written a lot of screen writing code in DOS, but I

Ace_new_return, ace_new, ace_new_noreturn for ACE network programming

The ACE source code OS _memory.h is defined in this way. # if defined (ACE_HAS_NEW_NOTHROW)# define ACE_NEW_RETURN(POINTER,CONSTRUCTOR,RET_VAL) \ do { POINTER = new (ACE_nothrow) CONSTRUCTOR; \ if (POINTER == 0) { errno = ENOMEM; return

Do... The use of while (false)

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.HoweverCodeBut I found some clever usage of do... while,

Linux Color output

Under Linux, you can use some macros, plus custom format output, to make the output easier to debug:Typesetting may be a bit messy, note do{}while (0); it's in one line.[CPP]View PlainCopy #include #include #define DEBUG1 (FMT, arg ...)

The little secrets of C language-Assertions

Every time I write a summary, I think it is a headache, because I know that the summary is really important, and it almost directly determines the number of readers. It may take a lot of effort to write things, because the failure of the abstract

In-depth understanding of the php kernel.

In-depth understanding of php kernel 1. I have a deep understanding of the php kernel and read the explanations used by 1do {} while (0). do {} while (0) is mainly used for the robustness and versatility of basic functions, and flexible use of some

Understanding the Linux kernel for interrupt saving and recovery

In the Linux kernel (linux-4.14.12/mm/slab.c#3389), at first glance at the bottom of the code, it seems that L3389 have a bug, so I read around the interest of a bit local_irq_save/local_irq_ The source code of the restore./*linux-4.14.12/mm/slab.c#3

Kernel synchronization and mutex Analysis Report

Article Title: synchronization and mutex Analysis Report in the kernel. Linux is a technology channel of the IT lab in China. Including desktop applications, Linux system management, kernel research, embedded systems, open source, and other basic

Key Excerpt from C language (1 ~ 5)

I. Basic data types: The data type can be understood as an alias with a fixed memory size. It is a model for creating variables. A variable is an alias for an actual Continuous Bucket. In a program, you can apply for and name a bucket through a

Total Pages: 15 1 .... 3 4 5 6 7 .... 15 Go to: Go

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.