青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

C++ Programmer's Cookbook

{C++ 基礎(chǔ)} {C++ 高級(jí)} {C#界面,C++核心算法} {設(shè)計(jì)模式} {C#基礎(chǔ)}

(vs.net2005 對(duì)c++library的二十個(gè)不兼容) -------Breaking Changes in Visual C++ 2005

There are a number of changes that you can expect to see in Microsoft Visual C++ 2005. In this article, I present a number of changes that can already be found in Visual C++ 2005 that you may encounter when upgrading your own programs. This information is based on a presentation and feedback by Brandon Bray (Visual C++ Program Manager), Alvin Chardon, and Sri Vasudevan. 

There will be a number of changes in Visual C++ 2005 that will break past programs. These changes have not been made casually—generally there is a strong reason for the change. As developers using Visual C++, you should be aware of these changes before you upgrade.

Allowing Change in Visual C++

The Visual C++ team has an entire process for considering changes in the product. It is considered very serious when a change is being made to Visual C++ that could break prior code. Even so, there are a number of reasons for breaking code in a new edition:

One of the key features of Visual C++ 2005 is that it is even more conformant with the C++ standards. This allows for more portable code across platforms and into other tools. Things such as lifetime of variables declared inside a for scope (for-scoping) and variable types will now fit the C++ standards. Conformance to the standards will also be the default settings in Visual C++ 2005. To gain this conformance, some things that were allowed in the past may no longer work.

Security has been a very hot topic over the past few years and will continue to be critical going forward. C++ allows you the power to do nearly anything. To help alleviate the number of security issues and to make code less error prone, Visual C++ 2005 has a number of changes. It introduced a secure CRT and deprecated the unsecure APIs. It also introduced the security checks that are on by default now.

Serviceability has also been added to the product. This allows for easier updateability of the binary files in VC++. It will now be easier for vulnerabilities to be patched and fixed.

Maintenance can also be a cause for making breaking changes. For example, low-value features may be removed from the product to eliminate the need to continue to maintain them. As an example, single-threaded CRT was removed from Visual Studio 2005 because it really wasn't needed. There are better alternatives and the time previously spent maintaining this can now be focused on more important issues.

Finally, a breaking change may be added in order to increase the reliability of the VC++ compiler. Microsoft wants to insure there is a well-defined and consistent behavior within Visual C++.

Some changes are avoided. Most changes to Visual C++ are at the source code level. If these changes impact backward binary compatibility, the change may not happen. Source compatibility will be broken before binary compatibility will be. A change will also be avoided if it could seriously cause people to avoid adopting or upgrading to 2005. This can be changes because of breaking code or because it adds cost. Finally, a coding change must have enough value to justify the cost of making the change. If the cost isn't justified, there is obviously no point in implementing it.

Ten Breaking Changes in the Visual C++ Library

There are a number of changes in the Visual C++ 2005 Libraries that could break your existing application code. Before upgrading to Visual C++ 2005, you should verify that you don't have any of these issues in your application code.

Parameter Validation

In the C Runtime Libraries, code has been added to validate parameters. For example, if you pass a destination buffer whose size is smaller than necessary to strcpy, you can cause a security risk. Parameter validation code will invoke an invalid parameter routine. In release, this will call Dr. Watson. In debug, it will assert. As long as you are passing valid parameters, this will not be an issue.

If you are passing invalid parameters, this will break your code.

Warnings for Insecure APIs

A set of functions within the CRT has been deprecated. New secure versions have been provided. Most of the deprecated functions can cause a buffer overrun or other security issue, if improperly used. These are functions such as strcpy, strcat, and so forth. The new, secure versions have been given a suffix of _s to make them easily identifiable. For example, functions include strycpys ,wcscpy_s, mbscpy_s, calloc_s, and strcat_s.

If you want to continue to use the old, insecure versions of these functions, you can use a #define value of _CRT_SECURE_NO_DEPRECATE. It is recommended, however, that you update your code to use the secure versions.

Iterators Out of Range

SCL checked iterators and debug iterators have been updated for security reasons. If you go out of range with a checked iterator, an "invalid parameter" routine will be called.

Again, you can avoid the invalid parameter and have an out-of-range exception thrown instead. This can be done by using the #define value of _SECURE_SCL_THROWS. By setting this define value to 1, an exception will be thrown instead of calling the invalid parameter handler.

You can turn this iterator checking off by setting the #defined value of _SECURE_SCL to zero. By default, this is turned on.

Type time_t

The type, time_t, is used to represent time in seconds from 1970. Up until 7.1, this was defined as a long. It is now of type 64-bit, so you can do times to the year 3000.

Linking to CRT

Managed applications cannot statically link to CRTs. Whereas you could build a CLR application in 7.0 and 7.1 by linking statically to the CRT, you cannot do that in 2005.

Single-Threaded CRT Support

Single-threaded CRT support has been removed. You had an option to link to the multi-threaded or single-threaded CRT. Going forward, it is believed that most people will want to work with the thread-safe multi-threaded routines.

_nolock suffix routines can be used to optimize your code. In exchange for being optimized, these functions are not thread safe.

Exception Handling

There are two types of exception handling that you could use: /EHa (asynchronous) and /EHs (synchronous). If you used the /EHs switch, on a catch(...) block you may or may not have caught structured exceptions; the behavior was undefined and thus unreliable. You are now guaranteed that structured exceptions will not be caught when /EHs is used. If you want to catch asynchronous exceptions, you should compile using the /EHa switch.

Order of Initialization

Behavior was not defined if you had both managed and native globals. If you had a managed and a native object that interacted, there was no guarantee as to which would be initialized first. Now, you are guaranteed that all native globals will be initialized first, followed by managed globals.

Printf

The %n format specifier in the printf set of functions will allow for printing the number of characters printed so far. This was a security risk and has thus been disabled. It can be enabled by using set_printf_count_output. Passing set_printf_count_output a 0 (zero) disables it. Passing any other value enables it.

The swprintf function

The swprintf function signature did not conform to the C++ standard, so it was changed to fit the standard. In C++, an overload was added with the appropriate arguments. The prior version of the method has been deprecated. In C, overloading is not allowed, so an error will be returned if you use the old format.

Compiler Breaking Changes

In addition to changes that will break the libraries, there are also changes that will break the compiler. The following are the top compiler breaking changes. Again, these are not all of the changes, but are rather the key items that the Microsoft QA team as well as internal partners and VC++ customers at Microsoft identified.

Pointers to Members

In previous versions, a pointer to a member could be obtained without using the address-of operator. Now, this functionality is conformant with standards. This should help to eliminate potential runtime errors. This fix caused a lot of changes in the MFC libraries, so it is possible it could cause issues in your programs as well.

Scoping Rules

Within for statements, scoping rules are not enforced by default. In prior versions, the lifetime duration of a for loop variable would live beyond the for statement. To be conformant with standards, this is no longer the case.

Type wchar_t

The wchar_t type is now built-in by default. There was a chance that you could have had wchar_t variables show as unsigned short because it wasn't built in. This could cause issues when trying to match up signatures with other files that did have wchar_t typed variables. In 2005, wchar_t is a built-in type. You will need, however, to make sure that your previous usage of this did not cause a translation to unsigned short.

Exception Handling

The compiler was changed to avoid catching structured exceptions to work with the library changes that were made. You should really be using /EHa anyway.

Attribute Parameters

To provide for more robust attributes, the compiler will now check against types, enumerations, and such. This means that you can get a compiler error on your attributes that you may not have gotten before.

Int by Default

Defaulting to an int is no longer accepted to conform to the C++ standard. It will still apply in C, but not C++. This change broke a lot of existing code for Microsoft, including NT code, so you will want to confirm your code doesn't break. It is always best to be explicit.

Managed Code with C

The C compiler should not be able to create managed code for the CLR. The C language is not object-oriented and thus doesn't fit with the model used for the CLR. Thus, any files compiled as C files will conflict with the CLR compiler flags. For example, if you use the /TC flag when compiling, you will have a conflict if any CLR flags are also used.

New Syntax to Target the CLR

By using the /clr option, the C++ compiler only accepts new syntax. This will help to enforce the new syntax added in Visual C++ 2005, as well as help to deprecate old code.

Security Checks

With security being the flavor of the day, it makes sense that the default for the security check switch (/GS) should be on. With 2005, /GS is now on by default.

In Conclusion

This article presents some of the key breaking changes as identified by Microsoft. This is not all of the changes, nor is this necessarily the ones that will impact you the most. The items presented here are the ones that were identified to be the most likely ones to cause you problems.

Ultimately, before upgrading or starting changes to your programs using the new version of the compiler, you should first try compiling your existing programs to verify that they don't break. If they do, the chances are you had an issue that should be fixed.


引自:http://www.codeguru.com/cpp/cpp/cpp_mfc/portability/article.php/c9523__3/

posted on 2005-12-27 17:04 夢(mèng)在天涯 閱讀(1436) 評(píng)論(0)  編輯 收藏 引用 所屬分類: CPlusPlus

公告

EMail:itech001#126.com

導(dǎo)航

統(tǒng)計(jì)

  • 隨筆 - 461
  • 文章 - 4
  • 評(píng)論 - 746
  • 引用 - 0

常用鏈接

隨筆分類

隨筆檔案

收藏夾

Blogs

c#(csharp)

C++(cpp)

Enlish

Forums(bbs)

My self

Often go

Useful Webs

Xml/Uml/html

搜索

  •  

積分與排名

  • 積分 - 1811983
  • 排名 - 5

最新評(píng)論

閱讀排行榜

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
      <noscript id="pjuwb"></noscript>
            <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
              <dd id="pjuwb"></dd>
              <abbr id="pjuwb"></abbr>
              亚洲午夜影视影院在线观看| 亚洲国产精品久久精品怡红院| 亚洲破处大片| 久久久综合视频| 亚洲一区二区三区视频播放| 欧美日韩麻豆| 亚洲视频精品在线| 亚洲国产日韩在线| 欧美日韩在线看| 性色av香蕉一区二区| 亚洲欧美激情视频| 亚洲国产日韩精品| 欧美激情91| 国产精品综合av一区二区国产馆| 久久精品国产99精品国产亚洲性色| 久久精品国产在热久久 | 欧美在线www| 91久久精品美女| 99pao成人国产永久免费视频| 国产日韩欧美中文在线播放| 欧美国产精品va在线观看| 欧美久久在线| 欧美诱惑福利视频| 国产精品美女久久久浪潮软件| 亚洲桃色在线一区| 欧美另类视频在线| 香港成人在线视频| 亚洲网址在线| 欧美大胆a视频| 欧美v国产在线一区二区三区| 国产精品成人v| 一本久道综合久久精品| 99精品视频一区| 欧美日韩国产综合视频在线| 亚洲日本aⅴ片在线观看香蕉| 亚洲人成小说网站色在线| 欧美91福利在线观看| 亚洲国产成人91精品| 亚洲激情视频网| 欧美日韩国产免费观看| 亚洲一区二区3| 久久精品视频免费播放| 在线观看日韩精品| 欧美连裤袜在线视频| 亚洲一区二区免费| 久久久之久亚州精品露出| 亚洲国产高清高潮精品美女| 久久综合网hezyo| 亚洲精选视频在线| 亚洲欧美日韩精品久久久久| 国产综合欧美在线看| 欧美成人精品三级在线观看| 亚洲午夜女主播在线直播| 蜜桃av一区二区三区| 一区二区三区视频免费在线观看| 国产乱码精品一区二区三区不卡| 久久久久久久精| 亚洲精品专区| 激情自拍一区| 欧美午夜电影在线观看| 久久人91精品久久久久久不卡| 亚洲黄色毛片| 久久综合网络一区二区| 欧美一级大片在线观看| 亚洲美女黄色| 99精品热6080yy久久| 亚洲字幕在线观看| 亚洲精品国精品久久99热| 美女91精品| 美玉足脚交一区二区三区图片| 午夜精品久久久99热福利| 亚洲在线一区二区三区| 中国亚洲黄色| 一区二区三区日韩| 一区二区三区精品国产| 一区二区av| 亚洲欧美一区二区三区久久| 亚洲欧美成人在线| 欧美在线视频在线播放完整版免费观看| 亚洲日本激情| 亚洲作爱视频| 欧美一区二区在线免费播放| 欧美一级黄色网| 久久永久免费| 亚洲韩国一区二区三区| 中日韩美女免费视频网址在线观看| 日韩午夜剧场| 久久亚洲色图| 欧美午夜一区二区福利视频| 国产日韩欧美综合一区| 91久久久久久| 欧美一级夜夜爽| 欧美福利一区二区| 亚洲视频观看| 欧美ed2k| 激情亚洲网站| 欧美怡红院视频| 亚洲精品123区| 亚洲欧美日韩成人| 欧美日韩国产限制| 亚洲国产va精品久久久不卡综合| 亚洲小说春色综合另类电影| 久久综合五月| 久久精品三级| 国产久一道中文一区| 亚洲私人影院在线观看| 亚洲国产婷婷综合在线精品| 久久久国产精彩视频美女艺术照福利| 欧美激情免费观看| 久久最新视频| 国产日韩欧美高清| 午夜精品久久久99热福利| 艳妇臀荡乳欲伦亚洲一区| 欧美超级免费视 在线| 黄色日韩网站视频| 欧美成人一品| 亚洲精品1234| 91久久精品美女| 欧美激情视频一区二区三区免费| 在线免费观看欧美| 欧美激情第二页| 欧美激情网友自拍| 亚洲视屏在线播放| 一区二区三区四区五区视频| 国产精品成人国产乱一区| 久久久夜夜夜| 亚洲精品中文字幕在线| 一区二区三区高清视频在线观看| 欧美日韩亚洲一区二| 午夜精品久久久久久| 欧美一区三区三区高中清蜜桃| 亚洲国产精品久久久久秋霞蜜臀| 亚洲人成在线观看一区二区| 欧美午夜在线视频| 久久久国产精品一区| 欧美精品在线一区| 久久精品国产综合| 欧美日韩国产一区精品一区| 久久国产主播| 欧美午夜精品理论片a级大开眼界 欧美午夜精品理论片a级按摩 | 麻豆视频一区二区| 欧美日韩精品一区二区三区四区| 欧美在线播放| 欧美精品二区| 久久阴道视频| 国产一区二区黄| 亚洲欧美日韩国产另类专区| 亚洲美女黄网| 欧美成人综合在线| 久久五月天婷婷| 国产欧美日韩激情| 宅男66日本亚洲欧美视频| 欧美中文字幕第一页| 亚洲午夜伦理| 国产精品福利av| 亚洲乱码精品一二三四区日韩在线 | 久久狠狠亚洲综合| 欧美制服丝袜第一页| 国产精品xxx在线观看www| 亚洲人在线视频| 亚洲精品一区二区三区四区高清| 久久免费精品日本久久中文字幕| 久久国产主播| 亚洲国产成人精品久久| 欧美福利网址| 这里只有精品视频在线| 亚洲欧美日韩另类| 好吊日精品视频| 欧美大片免费| 一区二区三区www| 久久大逼视频| 亚洲欧洲精品天堂一级| 欧美视频在线观看视频极品| 中文高清一区| 欧美大片免费观看| 午夜精品久久久| 亚洲精品色图| 国产日韩亚洲| 欧美日韩一区二区三区在线| 校园春色国产精品| 亚洲六月丁香色婷婷综合久久| 久久精品亚洲国产奇米99| 亚洲激情图片小说视频| 国产乱肥老妇国产一区二 | 麻豆精品网站| 亚洲免费视频在线观看| 亚洲国产激情| 女女同性精品视频| 久久精品国产欧美激情| 亚洲欧美中文日韩在线| 亚洲伦伦在线| 亚洲国产精品久久91精品| 国产午夜精品一区二区三区欧美 | 亚洲专区一区二区三区| 在线日韩av永久免费观看| 国产女主播一区二区三区| 欧美日韩亚洲一区在线观看| 欧美成人午夜激情在线| 久久综合久久综合久久| 久久精品视频网|