错误:使用的标签,但没有定义时使用&放大器;&安培;操作者 [英] Error: Label used but not defined when using && operator

查看:510
本文介绍了错误:使用的标签,但没有定义时使用&放大器;&安培;操作者的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  INT的main()
{
        INT I = 0;
        为int * p =&放;我;
        INT * Q =&功放​​;&安培;我;
        返回0;
}

在对编译的Linux使用本 GCC ,我收到错误

  addr.c:在函数'主':
addr.c:6:2:错误:标签'我'使用,但没有定义

为什么编译器处理 INT I 标签,而不是整数?我们什么时候使用&放大器;&安培;运营商

修改:好吧,我能有所了解的答案,但你能解释一下下面的宏定义从弓/ ARM /有/ ASM / processor.h。它不说,关于标签什么,但评论说,它可以返回了程序计数器

  / *
 *默认实现宏返回电流
 *指令指针(程序计数器)。
 * /
#定义current_text_addr()({__label__ _l; _l:放大器;&安培; _l;})


解决方案

&什么功放;&安培;运营商?有没有一元和放大器;&安培; C ++操作符。 GCC有一个扩展,允许相对goto语句,并且扩展使用和放大器;&安培;得到一个标号的地址

int main()
{
        int i = 0;
        int *p = &i;
        int *q = &&i;
        return 0;
}

When compiling this using gcc on Linux, I am getting the error

addr.c: In function ‘main’:
addr.c:6:2: error: label ‘i’ used but not defined

Why is the compiler treating int i as label and not integer? When do we use && operator?

EDIT: Okay, I can somewhat understand the answers, but can you explain the below macro definition from "arch/arm/include/asm/processor.h". It doesn't says anything about label, but the comment says, it can return the "program counter"

/*
 * Default implementation of macro that returns current
 * instruction pointer ("program counter").
 */
#define current_text_addr() ({ __label__ _l; _l: &&_l;})

解决方案

What && operator? There is no unary && operator in C++. GCC has an extension that allows computed goto statements, and that extension uses && to get the address of a label.

这篇关于错误:使用的标签,但没有定义时使用&放大器;&安培;操作者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆