(v)实际上是(*& v)自何时开始? [英] (v) is actually (*&v) since when?

查看:59
本文介绍了(v)实际上是(*& v)自何时开始?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请问C ++标准专家有什么帮助吗?

Could C++ standards gurus please enlighten me:

由于哪个C ++标准版本的声明失败,因为(v)等价于(*& v)

Since which C++ standard version has this statement failed because (v) seems to be equivalent to (*&v)?

即例如代码:

 #define DEC(V) ( ((V)>0)? ((V)-=1) : 0 )
 ...{...
        register int v=1;
        int r = DEC(v) ;
 ...}...

这现在在 -std =下产生警告c ++ 17 如:


无法获取寄存器变量的地址

cannot take address of register variable

左手

许多C宏都将所有宏参数括在括号中,以上仅作为示例。

Many C macros enclose ALL macro parameters in parentheses, of which the above is meant only to be a representative example.

产生警告的实际宏例如是
/ usr / include中的 RTA _ * 宏/linux/rtnetlink.h

The actual macros that produce warnings are for instance the RTA_* macros in /usr/include/linux/rtnetlink.h.

在C ++中不使用/重新定义这些宏的简短之处,有什么解决方法吗?

Short of not using/redefining these macros in C++, is there any workaround?

推荐答案

如果您查看最新的C ++ 1z草案的修订摘要,则会在 [diff.cpp14.dcl.dcl]

If you look at the revision summary of the latest C++1z draft, you'd see this in [diff.cpp14.dcl.dcl]


[dcl.stc]

更改:删除寄存器存储类说明符。

理论上::在此国际标准的将来
版中启用已弃用的关键字的用途。

对原始功能的影响:在本国际标准中,使用寄存器
storage-class-specifier的有效C ++ 2014声明格式错误。
只需删除说明符即可保留其原始含义。

[dcl.stc]
Change: Removal of register storage-class-specifier.
Rationale: Enable repurposing of deprecated keyword in future revisions of this International Standard.
Effect on original feature: A valid C++ 2014 declaration utilizing the register storage-class-specifier is ill-formed in this International Standard. The specifier can simply be removed to retain the original meaning.

警告可能是由于该原因。

The warning may be due to that.

这篇关于(v)实际上是(*& v)自何时开始?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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