c语言注释macros,c语言宏定义技巧(常用宏定义)(The C language macro definition techniques (commonly used macros)).doc...

c语言宏定义技巧(常用宏定义)(The C language macro definition techniques (commonly used macros))

c语言宏定义技巧(常用宏定义)(The C language macro definition techniques (commonly used macros))

The C language macro definition techniques (commonly used macros)

Written in C language, beautiful macro definition is very important, the use of macro definitions can prevent errors, improve portability, readability, convenience and so on. Here are some of the mature software commonly used in macro definition......

1, to prevent a header file contains repeated

#ifndef COMDEF_H

#define COMDEF_H

The contents of the file / head

#endif

2, re define types that prevent due to a variety of platforms and compilers of different types of bytes resulting from the difference, easy to transplant.

Typedef unsigned char Boolean Boolean value type.; / * * /

Typedef unsigned long int uint32 Unsigned bit value; / * * / 32

Typedef unsigned short uint16 Unsigned bit value; / * * / 16

Typedef unsigned char uint8 Unsigned bit value; / * * / 8

Typedef signed long int int32 Signed bit value; / * * / 32

Typedef signed short int16 Signed bit value; / * * / 16

Typedef signed char int8 Signed bit value; / * * / 8

The following / / not recommended

Typedef unsigned char byte Unsigned bit value type. 8; / * * /

Typedef unsigned short word Unsinged bit value type. 16; / * * /

Typedef unsigned long DWORD Unsigned bit value type. 32; / * * /

Typedef unsigned char uint1 Unsigned bit value type. 8; / * * /

Typedef unsigned short uint2 Unsigned bit value type. 16; / * * /

Typedef unsigned long uint4 Unsigned bit value type. 32; / * * /

Typedef signed char INT1 Signed bit value type. 8; / * * /

Typedef signed short INT2 Signed bit value type. 16; / * * /

Typedef long int int4 Signed bit value type. 32; / * * /

Typedef signed long sint31 Signed bit value; / * * / 32

Typedef signed short sint15 Signed bit value; / * * / 16

Typedef signed char sint7 Signed bit value; / * * / 8

3, given a byte or word address.

#define MEM_B (x) (* ((byte *) (x)))

#define MEM_W (x) (* ((word *) (x)))

4, the maximum value and the minimum value

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值