大师指点后,所做的笔记,很感谢一起愿意研究技术的同事,以下不是本人原创,是他分析的成果

#include <stdio.h>
#include <time.h> struct lock_class_key {
int ck;
}; #define mutex_init() \
do { \
static struct lock_class_key __key; \
static int a; \
\
printf("macro==>>Line=%d,&__key=0x%p &a=0x%p\n", __LINE__, &__key, &a); \
} while () void __mutex_init()
{
do {
static struct lock_class_key __key1;
static int a1;
printf("function==>>Line=%d,&__key1=0x%p &a1=0x%p\n", __LINE__, &__key1, &a1);
} while (); } int main(void)
{
//do { static struct lock_class_key __key; static int a; printf("macro==>>Line=%d,&__key=0x%p &a=0x%p\n", 28, &__key, &a); } while (0);===>宏展开就是这样的,gcc -E -o test.i test.c
//do { static struct lock_class_key __key; static int a; printf("macro==>>Line=%d,&__key=0x%p &a=0x%p\n", 29, &__key, &a); } while (0); //{ static struct lock_class_key __key; static int a; printf("macro==>>Line=%d,&__key=0x%p &a=0x%p\n", 28, &__key, &a); }
//{ static struct lock_class_key __key; static int a; printf("macro==>>Line=%d,&__key=0x%p &a=0x%p\n", 29, &__key, &a); } {static int b1;} //=======>这种括号是作用域,一个函数名本来只有一个作用域,但是如果函数里面加了这种,相当于是在两个作用域里面,是允许这样定义的,地址也会不同
//printf("fuck!!\n");
{static int b1;}
mutex_init();
mutex_init();
__mutex_init();
__mutex_init(); return ();
} 执行结果: macro==>>Line=,&__key=0x0x60104c &a=0x0x601050
macro==>>Line=,&__key=0x0x601054 &a=0x0x601058
function==>>Line=,&__key1=0x0x601044 &a1=0x0x601048
function==>>Line=,&__key1=0x0x601044 &a1=0x0x601048

最新文章

  1. 定时任务-在spring中配置quartz
  2. 如何实现标准TCODE的屏幕增强
  3. bzoj4025
  4. Calendar类的基本使用
  5. java中静态代码块,构造代码块,以及构造方法的执行顺序
  6. MongoDB基础教程系列--第七篇 MongoDB 聚合管道
  7. js前端实现多图图片上传预览
  8. bzoj1087 [SCOI2005][状压DP] 互不侵犯King (状压)
  9. UNIX网络编程——套接字选项(SO_RCVBUF和SO_SNDBUF)
  10. mysql大小写敏感(默认为1,不敏感)
  11. java接口入参模板化,适用于企业化服务远程调度模板化的场景,接口入参实现高度可配置化
  12. A. 【UR #4】元旦三侠的游戏
  13. Likecloud—吃、吃、吃(P1508)
  14. 微软新一代Surface,该怎么看?
  15. conductor元数据定义
  16. Gerrit 系统初探 (已转移到 https://steemit.com/gerrit/@linvictor88/gerrit )
  17. BZOJ2756:[SCOI2012]奇怪的游戏(最大流,二分)
  18. 天嵌IMX6开发板测试-第一篇
  19. Spring_Bean 之间的关系
  20. linux语言设置i18n(转)

热门文章

  1. 把python脚本打包成win可执行文件
  2. vue路由文档笔记
  3. 1066 Root of AVL Tree (25 分)(平衡二叉树)
  4. Python 3 学习笔记之——变量作用域、模块和包
  5. c#执行插入sql 时,报错:异常信息:超时时间已到。在操作完成之前超时时间已过或服务器未响应
  6. HDU 4717 The Moving Points(三分法)(2013 ACM/ICPC Asia Regional Online ―― Warmup2)
  7. 【解决】Node JS Error: ENOENT
  8. ubuntu 和 centOS 的apache设置
  9. Unity3D - UGUI实现Tab键切换输入框、按钮(按Tab键切换高亮显示的UI)
  10. [C/C++] extern关键字详解以及与static、const区别