可在未知属性编译器报告错误?即使使用范围是什么? [英] May a compiler report errors on unknown attributes? Even with scope?

查看:125
本文介绍了可在未知属性编译器报告错误?即使使用范围是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在N3291的7.6.1。(3/5)属性的语法和语义[decl.attr.grammar]的有关如何的属性写在源code我读

In N3291 "7.6.1.(3/5) Attribute Syntax and semantics [decl.attr.grammar]" concerning how attributes are written in source code I read

使用的属性范围的令牌的有条件支持,与
   实现定义的行为。

The use of an attribute-scoped-token is conditionally-supported, with implementation-defined behavior.

对于属性标记的不在本标准规定,该行为是实现定义的。

For an attribute-token not specified in this International Standard, the behavior is implementation-defined.

这是否意味着,该属性规范,比如

Does this mean, that attribute specifications like

[[ dllexport ]]
[[ hiding ]]
[[ unused ]]
[[ vendor::attrib ]]

可以通过的符合标准的编译器的可抱怨?因此,它的可能会报告错误并停止编译?

may be complained about by a standard conforming compiler? So, it could report an error and stop compilation?

我本来希望编译器的应该忽略属性,它不知道如何处理它们。好吧,这可能是危险的,因为属性拼写错误可能被忽略,例如 [noretrun] [carrys_dependencie] : - )

I would have hoped that a compiler should ignore attributes that it does not know how to handle them. Ok, that might be dangerous, because typos in attributes may be overlooked, for example [[ noretrun ]] or [[ carrys_dependencie ]] :-)

但是,尤其是命名空间,将有助于在这里,对不对?当我编译 [GCC :: MIPS] 上的微软编译器的一个人应该能够忽略,而不是拒绝它,对吗?

But especially namespaces would help here, right? When I compile [[ gcc::mips ]] on an Microsoft compiler that one should be able to ignore that and not reject it, right?

推荐答案

它的 的可以做任何事情;这就是实现定义的意思。

It could do anything; that's what "implementation defined" means.

属性规范的目的是为了让编译器厂商将停止混乱的语言了特殊的语法和关键字。给他们一个单一的语法指定这些东西。它是一个编译器定义的字符串与特定对象或定义相关联的方法。

The purpose of the attribute specification is so that compiler makers will stop cluttering the language up with special syntax and keywords. To give them a single grammar for specifying these things. It is a way to associate a compiler-defined string with a particular object or definition.

现在,pretty很多人支持新的属性语法。因此,尽管它的可能的做任何事情,它不会做的任何的在present。

Right now, pretty much nobody supports the new attribute syntax. So while it could do anything, it doesn't do anything at present.

这篇关于可在未知属性编译器报告错误?即使使用范围是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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