惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google DeepMind News
Google DeepMind News
博客园_首页
H
Help Net Security
T
Tailwind CSS Blog
S
SegmentFault 最新的问题
GbyAI
GbyAI
Scott Helme
Scott Helme
D
Docker
Hacker News: Ask HN
Hacker News: Ask HN
P
Privacy & Cybersecurity Law Blog
Jina AI
Jina AI
雷峰网
雷峰网
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Spread Privacy
Spread Privacy
G
GRAHAM CLULEY
C
Cisco Blogs
The Hacker News
The Hacker News
F
Full Disclosure
Y
Y Combinator Blog
Blog — PlanetScale
Blog — PlanetScale
Recent Announcements
Recent Announcements
G
Google Developers Blog
量子位
K
Kaspersky official blog
Cisco Talos Blog
Cisco Talos Blog
The Cloudflare Blog
A
About on SuperTechFans
C
Cybersecurity and Infrastructure Security Agency CISA
Last Week in AI
Last Week in AI
博客园 - 三生石上(FineUI控件)
Microsoft Security Blog
Microsoft Security Blog
Martin Fowler
Martin Fowler
T
Tenable Blog
P
Palo Alto Networks Blog
H
Heimdal Security Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
W
WeLiveSecurity
Schneier on Security
Schneier on Security
The Register - Security
The Register - Security
F
Fortinet All Blogs
Stack Overflow Blog
Stack Overflow Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
T
The Blog of Author Tim Ferriss
N
News and Events Feed by Topic
Hugging Face - Blog
Hugging Face - Blog
小众软件
小众软件
V
V2EX
爱范儿
爱范儿

博客园 - 山本二十八

【转】ext4+delalloc造成单次写延迟增加的分析 write 系统调用耗时长的原因 【转】通过blktrace, debugfs分析磁盘IO win7 wifi热点 【SystemTap】 Linux下安装使用SystemTap源码安装SystemTap pdflush进程介绍与优化【转】 How to find per-process I/O statistics on Linux oom_killer 磁盘性能统计 利用ftrace跟踪内核static tracepoint Tracing on Linux 【转】ftrace 简介 buffer与cache的区别 fio使用 linux分区 Valgrind查找内存泄露利器 取得进程信息 打印堆栈信息 shell调试技术
局部标签(gcc对c的扩展)
山本二十八 · 2013-07-26 · via 博客园 - 山本二十八

每个语句内嵌表达式都是一个可以声明局部跳转标签的域。一个局部标签只是一个标识符:你可以使用通常的goto语句跳到它--但是只能在它所属的域内这么做。
一个局部标签的申明如下:
__label__ label;
或者:
__label__ label1, label2, ...;
局部标签的申明必须在语句内嵌表达式的开始出,紧跟({后面,在所有通常申明的左边。局部标签申明只是定义了标签的名字,但是并没有定义标签本身。 你必须用通常的标签使用方法来在语句内嵌表达式内部使用局部标签。

由于语句内嵌表达式经常用于宏,所以局部标签特性非常有用。如果在宏里包含了循环,一个goto能很有效的跳出循环。然而通常的标签的作用域式整个函数,如果宏在一个函数中被多次使用,标签就会在这个函数中被重复定义。而局部标签能避免这个问题。例如:

#define SEARCH(array, target)               \
({                                 \
__label__ found;                     \
typeof (target) _SEARCH_target = (target);     \
typeof (*(array)) *_SEARCH_array = (array);   \
int i, j;                           \
int value;                         \
for (i = 0; i < max; i++)               \
  for (j = 0; j < max; j++)               \
    if (_SEARCH_array[j] == _SEARCH_target) \
    { value = i; goto found; }           \
value = -1;                         \
found:                             \
value;                             \
})