Table of Contents
深入理解php内核阅读1
Home php教程 php手册 深入理解php内核阅读1

深入理解php内核阅读1

Jun 13, 2016 am 08:54 AM
Kernel

深入理解php内核阅读1

do{ }while(0)使用的解释

 

 do{ }while(0)写法的目的主要是为了程序基础函数的健壮性和通用性,和一些代码的灵活使用。

 do{ }while(0)写法会让内部的代码执行一次后退出,如果不使用这种写法,会对那些如if语句后面不紧跟{}的程序员造成编译错误,而对那些使用{}编程习惯的则无影响。

举例:

#define SAFE_DELETE(p) do{ delete p; p = NULL} while(0)  //1.使用 do{ }while(0)写法

#define SAFE_DELETE(p)  { delete p; p = NULL} //2.使用{}写法

#define SAFE_DELETE(p)  delete p; p = NULL  //3.什么都不使用的写法

 

if(NULL != p) SAFE_DELETE(p)     //1.无问题 2.无问题 3.有问题,else前面有2条语句,编译失败

else   ...do sth...

 

if(NULL != p) SAFE_DELETE(p);     //1.无问题 2.有问题,括号后面跟;编译失败 3.有问题,else前面有2条       else   ...do sth...                                 //语句,编译失败

 

 

if(NULL != p) {SAFE_DELETE(p)}     //1.无问题 2.无问题 3.无问题

else   ...do sth...

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Two Point Museum: All Exhibits And Where To Find Them
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to install the Linux kernel on Ubuntu 22.04 Detailed tutorial! How to install the Linux kernel on Ubuntu 22.04 Detailed tutorial! Mar 01, 2024 pm 10:34 PM

To install the Linux kernel on Ubuntu22.04, you can follow the following steps: Update the system: First, make sure your Ubuntu system is the latest, execute the following command to update the system package: sudoaptupdatesudoaptupgrade Download the kernel file: Visit the official Linux kernel website () to download Required kernel version. Select a stable version and download the source code file (with .tar.gz or .tar.xz extension), for example: wget Unzip the file: Use the following command to unzip the downloaded kernel source code file: tar-xflinux-5.14.tar. xz install build dependencies: Install the tools and dependencies required to build the kernel. Execute

Modify Linux kernel startup sequence Modify Linux kernel startup sequence Feb 23, 2024 pm 10:22 PM

Modify the kernel startup sequence of Linux 1. Modify the kernel startup sequence of RHEL6/CentOS6. Check the /etc/grub.conf file to determine the system kernel situation. According to the document, there are two kernel versions in the system, namely 2.6.32-573.18.1.el6.x86_64 and 2.6.32-431.23.3.el6.x86_64. Kernel versions are listed from top to bottom. In the grub.conf file, you can decide which kernel version to use when the system starts by adjusting the default parameters. The default value is 0, which means the system will boot the latest kernel version. A value of 0 corresponds to the first content listed in the grub.conf file.

Is the Android system based on the Linux kernel? Is the Android system based on the Linux kernel? Mar 14, 2024 pm 03:12 PM

Is the Android system based on the Linux kernel? Android system, as one of the most widely used mobile operating systems in the world, has always been said to be developed based on the Linux kernel. However, what is the real situation? Let’s explore this issue. First, let's understand the Linux kernel. The Linux kernel, as an open source operating system kernel, was first released by Linus Torvalds in 1991. It provides a good foundation for many operating systems, including And

Linux kernel main function analysis and analysis Linux kernel main function analysis and analysis Mar 14, 2024 am 11:27 AM

Linux kernel main function analysis and analysis The Linux kernel is a large and complex system, in which the main function plays a vital role. It is the entry point of the entire system and is responsible for initializing various subsystems, drivers and kernel modules. Finally start the entire operating system. This article will analyze and analyze the main function of the Linux kernel, and demonstrate its key functions and execution flow through specific code examples. In the Linux kernel, the entry point of the main function is start_k in the init/main.c file.

Explore the programming languages ​​used under the hood of the Linux kernel Explore the programming languages ​​used under the hood of the Linux kernel Mar 20, 2024 am 08:06 AM

Title: Exploring the programming language used at the bottom of the Linux kernel. As an open source, stable and reliable operating system kernel, the Linux kernel has a wide range of applications in the computer field. To have an in-depth understanding of the Linux kernel, you have to involve the programming language used at the bottom. In fact, the Linux kernel is mainly written in C language, which is an efficient, flexible and easy-to-maintain programming language that is very suitable for operating system development. This article will explore the bottom of the Linux kernel from a detailed perspective

Detailed explanation of Linux kernel source code storage location Detailed explanation of Linux kernel source code storage location Mar 14, 2024 pm 06:12 PM

Detailed explanation of the storage location of Linux kernel source code. Linux kernel source code is the core part of the Linux operating system. It contains the implementation code for various functions of the operating system. To understand where the Linux kernel source code is stored, we first need to understand the organizational structure of the Linux kernel. Linux kernel source code is usually stored in the /usr/src/linux or /usr/src/linux- directory. In this directory, there are many

Ubuntu compilation and installation kernel tutorial. Ubuntu compilation and installation kernel tutorial. Feb 19, 2024 pm 02:54 PM

Compiling and installing the Ubuntu kernel requires certain professional skills and practical experience. Here are the general steps, but please proceed with caution as this process may carry certain risks. Before you begin, be sure to back up important data and systems. Get the source code: Visit the Ubuntu official website () or the kernel developer website () to download the latest kernel source code. Unzip the source code to a suitable directory, such as /usr/src. Install compilation dependencies: Install the dependencies required to build the kernel. Open a terminal and execute the following command: sudoapt-getinstallbuild-essentiallibncurses-devbisonflexlibssl-devlibelf-d

CentOS 7 kernel upgrade tutorial. CentOS 7 kernel upgrade tutorial. Feb 18, 2024 pm 05:33 PM

Upgrading the kernel on CentOS7 requires the following steps: Check the current kernel version: Open a terminal and run the following command: uname -r Add ELRepo source: Run the following command to add the ELRepo source: rpm --import Install new kernel: Run the following command to install Latest stable kernel: yum --enablerepo=elrepo-kernelinstallkernel-ml Update boot manager (GRUB) configuration: Run the following command to update the GRUB configuration file: grub2-mkconfig -o/boot/grub2/grub.cfg Restart the system: Run The following command is used to restart the system: reboot verification

See all articles