在C ++中注册关键字 [英] Register keyword in C++

查看:153
本文介绍了在C ++中注册关键字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

int x=7;

register int x=7;

推荐答案

在C ++中,任何使用关键字auto或register的有效程序在语义上都与一个删除这些关键字(除非它们出现在字符串宏或其他类似的上下文中)。在这个意义上,关键字对于正确编译程序是无用的。另一方面,关键字可能在某些宏上下文中有用,以确保宏的不当使用将导致编译时错误,而不是产生伪代码。

In C++, any program which is valid that uses the keywords "auto" or "register" will be semantically identical to one with those keywords removed (unless they appear in stringized macros or other similar contexts). In that sense the keywords are useless for properly-compiling programs. On the other hand, the keywords might be useful in certain macro contexts to ensure that improper usage of a macro will cause a compile-time error rather than producing bogus code.

这篇关于在C ++中注册关键字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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