残培是去precated [英] getch is deprecated

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

问题描述

某处时光倒流我做了一些C和C ++在大学,但我没有得到很多关注C ++。现在,我想给予一些关注,C ++,但是当我使用残培()功能,我从下面得到警告。

Somewhere back in time I did some C and C++ in college, but I didn't get to many attention to C++. Now I wish to pay some attention to C++ but when I'm using the getch() function, I get the warning from below.

警告C4996:残培:POSIX的名字为这个项目是pcated德$ P $。相反,使用ISO C ++一致性名称:_getch。详细信息请参见在线帮助。

Warning C4996: 'getch': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _getch. See online help for details.

现在,我使用VS 2005的前preSS,我不知道该怎么办有关此警告。我需要使用残培()后,我的printf()需要一个键击错误消息或别的东西。

Now, I'm using VS 2005 express, and I don't know what to do about this warning. I need to use getch() after I printf() an error message or something else which require a key hit.

您能帮我吗?

推荐答案

微软决定不标注下划线pcated德$ P $的名字,因为这些名称是保留给程序员选择。如果他们想坚持到C或C ++标准实施特定的扩展应该使用开始在全局命名空间中的下划线的名字 - 或者他们本身应该标记为组合符合标准的环境,如POSIX / ANSI / ISO C,其中这样的然后函数对应这些标准中的一个。

Microsoft decided to mark the name without underscore deprecated, because those names are reserved for the programmer to choose. Implementation specific extensions should use names starting with an underscore in the global namespace if they want to adhere to the C or C++ Standard - or they should mark themselves as a combined Standard compliant environment, such as POSIX/ANSI/ISO C, where such a function then corresponds to one of those Standards.

读<一个href=\"http://stackoverflow.com/questions/647704/why-is-getcwd-not-iso-c-compliant/647802#647802\">this关于GETCWD答案()也由P. J. Plauger,谁知道的东西非常好,当然解释。

Read this answer about getcwd() too, for an explanation by P. J. Plauger, who knows stuff very well, of course.

如果你只关心等待用户键入某些键,实在是没有理由不使用的getchar 。但有时它只是更实用,方便了用户使用 _getch 和朋友。然而,这些不是由C或C ++标准规定,因此将限制程序的可移植性。记住这一点。

If you are only interested to wait for some keys typed by the user, there really is no reason not to use getchar. But sometimes it's just more practical and convenient to the user to use _getch and friends. However, those are not specified by the C or C++ Standard and will thus limit the portability of your program. Keep that in mind.

这篇关于残培是去precated的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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