警告:获取标签的地址是不标准的

warning: taking the address of a label is non-standard

本文关键字:地址 不标准 标签 获取 警告      更新时间:2023-10-16

有人能解释一下下面的代码是如何创建标签的吗?

char memory[] = "hello";
&&memory[0];
error: label 'memory' used but not defined
&&memory[0];

这不是有效的C++,因此一个一致的扩展可以为它分配任何想要的语义

碰巧的是,&&label是GNU人员为计算goto(GNU扩展)获取标签地址的方式。

就是这样。

参考:https://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html