#define ----typedef(关键字) 5个功能学习
来源:互联网 发布:windows 文件夹映射 编辑:程序博客网 时间:2024/05/24 01:47
- 宏:#define (关键字) (gcc -E test.c -o test.i)查看宏的替换
#define SIZE 20 //宏的名称用大写 三段 用空格键分割
#define INT8 char#define INT16 short#define INT32 int#define UINT8 unsigned char#define LONG (long long)
说明 :char short int float long double (long long)
32位 1 2 4 4 4 8 8 (4字节对齐)
64位 1 2 4 4 8 8 8 (8字节对齐)
tpyedef //关键字 ,取别名
typedef int int_t;typedef long long_t;
//这个结构体 有两个名字———–struct People——–people——
typedef struct
{
int age;
char sex;
}people;
2、头文件的定义(防止我们重复定义头文件)
#define _TEST_DEFINE_H
#define _TEST_DEFINE_H
//——————————–
extern int sum(int x,int y);
//———————————
#endif
3、运算
#define SUM(a,b) ( a+b )
#define MAX(a,b) ( a>b ? a:b )
#define MIN(a,b) ( a>b ? b:a )
#define SQURAE(x) ( x*x )
#define SQURAE(x) ( (x)*(x) )
4、代码注释
#define TEST_LOG
#ifdef TEST_LOG
void test_log(void)
{
//—————————–
}
#endif
#ifdef VOICES
void test_voices(void)
{
//————————-
}
#endif
void test_video(void)
{
//—————————
}
5、字符串连接 (# ##)
#define MY_STRACT(a,b) ( a#b )
#define ERR_LOG(fmt,args…) printf(fmt,##args)
//#define BUG
#ifdef BUG
#define ERR_LOG(fmt,args…) printf(fmt,args)
else
#define ERR_LOG(fmt,args…) {} //空操作,什么也不执行
6、地址操作
#define LED_PIN_A ( ( volatile unsigned shotr * )0x1002 )
- #define ----typedef(关键字) 5个功能学习
- 关键字typedef用法与#define用法
- 关键字typedef与#define的异同
- typedef关键字学习
- 深入学习C语言系列(二): #define与typedef
- 深入学习C语言系列(二): #define与typedef
- C++关键字(static/register/atuo/extern/volatile/const/inline/define/typedef)
- typedef&#define
- typedef & define
- typedef、define
- typedef define
- typedef define
- typedef define
- typedef #define
- define typedef
- Typedef & # define
- C/C++关键字static,const,inline,define,typedef
- [转]C/C++关键字static,const,inline,define,typedef
- 290. Word Pattern
- Tju1053/SSL1229 技能树 树形dp
- HTML解析原理
- Geekband作业12--寻找内存泄漏
- 测试shader的性能
- #define ----typedef(关键字) 5个功能学习
- 读书笔记之类似qq的侧滑菜单
- 【day0414 C++】queue 队列的使用
- 优化总结
- TranslucentBar 实际
- 致敬科比
- 2016年某某公司笔试题
- opengl入门(ubuntu版)(一)
- LeetCode——007