Detailed explanation of being processing

1.predefined symbol(we can view it as some can deirectly be used constants)

for example,

2.#define define constants

Now we supplement some knowledges.

(1)The storage device on the computer

1.memory 2.hard disk 3.register(on the cpu,reading speed very fast)

A code --> register int num;//meaning -- advice put the value of num in the register.

(we often use it when this variable need to be used repeatedly but whether use it depend on the complier judgement)

(2)for(;;) if the judgement write nothing,representing constantly true,which is dead circle.

(3)#define .... At last better not to add ;

A #define using example.

3.#define define macro

format -- #define name(parameter) stuff // do not need";" and the name and "(" need fit closely.

function-- parameter do not calculate and direct put in stuff.

for example,

#undef can cancel a #define

or

so we should remind add () when we use #define

4.side effect

b = a++

a++ is side effect.

when a macro parameter have side effect,it also will make some surprise situations.

5.Some positive and negative between marco and function

Characteristic

The string content will not be search.

Positive

(1)marco performance more better amd running more fast than function because marco just replace the code but function need stack creating to run.

(2) marco perameter need not type but function need.

(3)marco can directly deliver type.

Negative

(1)marco just direct replace the code,so it will add coding length.

(2)marco can not debug because the switch it is running in preprocessing progress but debug just test the program code.

(3)The operator precedence also have question.

(4)marco can not recurse.Can #define itself.

6.

7.#

make parameter in the string that can not be change be the object signal and make it stringify.

8.##

Creating a function mold

A using situation example

9.marco name always all capitalize while function name always not all capitalize

10.conditional comliation directive

1.ifdef

2.#if

do not use variable because this coding all processing in preprocessing but in this time just constant having and variable is not created.

3.branch

4.#if defined(M) if M is defined dy #define ,it will be true which is at the same of #ifdef

5.#if !defined(M) if M is not defined by #define ,it will be true which is at the same of #ifndef

5.head document including

#include <...> standard head document

#include "..." customize head document

#include "..." first will find the path of the source file's directory(文件所在目录的路径)

if not find ,it will find the standard library haed document.

#include <...> just will find the standard library haed document.

6.File nesting

A head document possbility will be used many times.

So we should have some idea to reduce repeat use.

1.#ifndef TEST_H

//first time will do in it

#define TEST_H//put this twe codes in head document head

//when define it,the last time can not put in it

....

#endif // put this code in the document last

2.#program once

using it can directly make this document just using once.

At last I tell something I found.

A variable just a digital.Like a int * p.The p essence is a digital.In pointer, it will be viewed as a address.

In pointer,it save just a address but by it type,it will control the address memory by the type manner.

for example,

//指针是带有有色眼镜的,它看内存的方式只和她的类型有关。

Like it ,using 0 to be the struct start address to calculate it offset.we can not visit the value but we can using pointer to find the struct member address.

相关推荐
.Ashy.1 小时前
2026.4.11 蓝桥杯软件类C/C++ G组山东省赛 小记
c语言·c++·蓝桥杯
2401_892070981 小时前
链栈(链式栈) 超详细实现(C 语言 + 逐行精讲)
c语言·数据结构·链栈
cmpxr_5 小时前
【C】局部变量和全局变量及同名情况
c语言·开发语言
网域小星球7 小时前
C 语言从 0 入门(十七)|结构体指针 + 动态内存 + 文件综合实战
c语言·开发语言·文件操作·结构体指针·动态内存·综合项目
lcj25118 小时前
【C语言】数据在内存中的存储
c语言·数据结构
特立独行的猫a9 小时前
OpenHarmony平台移植 gifsicle:C/C++ 三方库适配实践(Lycium / tpc_c_cplusplus)
c语言·c++·harmonyos·openharmony·三方库适配·lycium
yashuk12 小时前
C语言 vs. C++ ,哪个更适合初学者?
c语言·c++·面向对象编程·初学者·学习路径
泛凡(Linyongui)12 小时前
PY32F002B实践之四--宠物腹背理疗仪项目踩坑及项目总结复盘
c语言·keil·32位单片机·腹背理疗仪项目实践·普苒py32
Hello小赵12 小时前
C语言如何自定义链接库——编译与调用
android·java·c语言
JaneHan_12 小时前
STM32CubeMX+HAL+Keil5 PWM呼吸灯
c语言·stm32·单片机