标准变化 [英] standard change

查看:71
本文介绍了标准变化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

标准必须有一些变化,因为我遇到了这个错误

我把这行放在标题中。

#pragma once

我只希望标题包含一次。编译器说了一些关于过时的事情




----- =通过Newsfeeds.Com发布,未经审查的Usenet新闻= --- -
http://www.newsfeeds.com - #1新闻组世界上的服务!

----- ==超过100,000个新闻组 - 19个不同的服务器! = -----

解决方案

*这样说起Bill Cunningham< no **** @ nspam.net>:


你好,

我只想把标题包含一次。




使用?include后卫?它们是标准的,#pragma曾经不是。

Wolfgang。

-

" Erfahrungen - das sind die vernarbten Wunden unserer Dummheit 。

- John Osborne


" Bill Cunningham" <无**** @ nspam.net>写道:

标准中必须有一些变化,因为当我把这一行放在标题中时我遇到了这个错误。
#pragma once
我只希望将标题包含一次。编译器说过了一些关于过时的东西。




编译指示的行为是实现定义的(除了少数例外情况
C99中的
) ,但是`#pragma once''不是其中之一)。因此,编译器

实现者可以在不违反标准的情况下更改或弃用某些pragma

的含义。


< OT> ;

如果有问题的编译器是GCC C编译器:尽管在当前版本中标记为过时的
,`#pragma once''将继续

适用于未来版本。


引自< http://gcc.gnu.org/gcc-3.4/changes.html>:

|预处理器中的文件处理已被重写。海湾合作委员会不再

|通过符号链接和硬链接感到困惑,现在有一个正确的

|执行#import和#pragma一次。这两个指令有

|所以一直没有弃用。

< / OT>


<更多OT>

难道不应该反义词弃用是预先的而不是

取消弃用? ;)

< /更多OT>


Martin


Bill Cunningham写道:< blockquote class =post_quotes>标准中必须有一些变化因为我把这行放在标题中时遇到了这个错误。
#pragma once
我只想要标题被包括一次。编译器说了一些关于过时的东西。




直到C99,没有特定的#pragma具有标准定义的含义。

使用新标准,我们有一些#pragmas,意思是希望

具有超过特定于实现的含义。这些包括

#pragma STDC FP_CONTRACT开关开关

#pragma STDC FENV_ACCESS开关开关

#pragma STDC CX_LIMITED_RANGE on-关闭开关

其中开关是ON,OFF和DEFAULT之一

这9种形式可能已由其他我不知道的形式补充,但是

#pragma一次

已经_never_标准。由于系统头至少是从C99,

幂等,并且使用普通防护装置可以有效地制作头部,

不需要''#pragma一次正如你所描述的那样。


-

Martin Ambuhl


There must be some change in the standard because I ran into this error when
I put this line in a header.
# pragma once
I only wanted the headers to be included once. The compiler said something
about obsolete.


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----

解决方案

* Thus spoke Bill Cunningham <no****@nspam.net>:

Hallo,

I only wanted the headers to be included once.



Use ?include guards?. They are standard, #pragma once is not.
Wolfgang.
--
"Erfahrungen -- das sind die vernarbten Wunden unserer Dummheit."
-- John Osborne


"Bill Cunningham" <no****@nspam.net> writes:

There must be some change in the standard because I ran into this
error when I put this line in a header.
# pragma once
I only wanted the headers to be included once. The compiler said
something about obsolete.



The behavior of pragmas is implementation-defined (with a few exceptions
in C99, but `#pragma once'' is not one of them). Therefore, the compiler
implementor can change the meaning of or deprecate certain pragmas
without violating the standard.

<OT>
In case the compiler in question is the GCC C compiler: Despite being
marked obsolete in the current version, `#pragma once'' will continue to
work in future versions.

To quote from <http://gcc.gnu.org/gcc-3.4/changes.html>:
| File handling in the preprocessor has been rewritten. GCC no longer
| gets confused by symlinks and hardlinks, and now has a correct
| implementation of #import and #pragma once. These two directives have
| therefore been un-deprecated.
</OT>

<even more OT>
Shouldn''t the antonym of "deprecate" be "precate" instead of
"un-deprecate"? ;)
</even more OT>

Martin


Bill Cunningham wrote:

There must be some change in the standard because I ran into this error when
I put this line in a header.
# pragma once
I only wanted the headers to be included once. The compiler said something
about obsolete.



Until C99, no particular #pragma had a meaning defined by the standard.
With the new standard, we have a handful of #pragmas with meanings hoped to
have more than implementation-specific meanings. These include
#pragma STDC FP_CONTRACT on-off-switch
#pragma STDC FENV_ACCESS on-off-switch
#pragma STDC CX_LIMITED_RANGE on-off-switch
where on-off-switch is one of ON, OFF, and DEFAULT
These 9 forms may have been supplemented by others that I don''t know, but
#pragma once
has _never_ been standard. Since system headers are, at least from C99,
idempotent, and with normal guards your headers can be made effectively so,
there is no need for ''#pragma once'' as you describe it.


--
Martin Ambuhl


这篇关于标准变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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