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

C++ Programmer's Cookbook

{C++ 基礎} {C++ 高級} {C#界面,C++核心算法} {設計模式} {C#基礎}

C++ Breaking Changes in vs.net 2005

Introduction

Microsoft have made over 20 breaking changes to the C++ compiler for Whidbey. The Microsoft development team would love to get feedback on these changes and so have provided the following explanations, workarounds, scenarios and rationales behind their decision to change the compiler.

Note this is preliminary information and is subject to change.

 

1. Pointer-to-members now require qualified name and &.

Affected User Scenario:

Code written for previous versions of the compiler that just use the method name will give an error 

Description:

This is Standard C++.  Conformance demands that in order to create a pointer to a member function, the address of operator (&) is used with the fully qualified name of the method. 

Customer Workaround:

Customer should fully qualify his method name and use the address of operator (&) in order to create a pointer to a member function.  It's a common cause for bugs when we can't tell if the customer just forgot a parenthesis in a function call versus he wants to create a pointer to a member function. 

Rationale:

Our rationale for making this enforcement other than conform to the C++ Standard, is that in many cases it lead customers to logical bugs in their code due missing parenthesis in function calls.  Using the function's name without an argument list results in a function pointer which is convertible to several types, thus the code would have compiled leading to unexpected behavior at runtime.

2. __asm int 3 now generates native code

Affected User Scenario:

Customers that want their code to generate MSIL and use the __asm int 3 instruction to generate a break point will need to modify their code. 

Description:

Before __asm int 3 was translated by the compiler to a CLR break instruction and did not cause native code to be generated when compiled with /clr. 

Customer Workaround:

Customer must now use __debugbreak so that the function may be compiled to MSIL and still act as a break point. 

Rationale:

We want to be more deterministic about when we generate native code or managed code instead of special casing inline assembly code when targeting the CLR.  Inline assembly code should generate native code.

3. Explicit  specialization not allowed as a copy constructor/copy assignment operator

Affected User Scenario:

Users that depended on an explicit template specialization for a copy constructor or copy assignment operator in their code will now get compiler error C2299. 

Description:

Standard C++ prohibits this and as so we changed it to be conformant.  Users will need to update their code. 

Customer Workaround:

Customer workaround is to stop making the copy constructor/copy asignment operator a template function and just make it a regular function that takes a class type with the desired template arguments.  Any code that calls the copy contructor/copy assignment operator  by explicitly specifying the template arguments needs to remove the template arguments. 

Rationale:

C++ Standard conformance is always on our list of priorities; users expect their code to be portable.  We made this change to be conformant. 

4. Unspecialized class template can't be used as a template argument in a base class list

Affected User Scenario:

Users that use an unspecialized template class name in the base class list for a the class' definition will see a compiler error. 

Description:

It is illegal to use an unspecialized template class name as a template parameter in a base class list.  Elsewhere inside the class, the compiler injects the unspecialized type parameter 

Customer Workaround:

User needs to explicitly add the template type parameters to the template class name when using it as a template parameter in a base class list. 

Rationale:

C++ Standard conformance is always on our list of priorities; users expect their code to be portable.  We made this change to be conformant. 

5. A using declaration of nested type is now illegal

Affected User Scenario:

Customers that have a using declaration with a nested type  will now get C2885. 

Description:

Before users where allowed to bring in a nested type's declaration to global scope by a using declaration.  This is not allowed in Standard C++. 

Customer Workaround:

Customer workaround is to fully qualify his nested type whenever he wants to use it.  A typedef can also be used to bypass using the scope resolution operator everywhere. 

Rationale:

The using declaration cannot be used with nested classes, the C++ Standard specifies that it can be used to bring a class into the scope that is contained in a namespace, not a class. 

6. Compiler no longer allows const_cast to down cast in the old syntax.

Affected User Scenario:

Users were incorrectly allowed to use const_cast to down cast (cast down the hierarchy to a more derived class type) with our 7.0 and 7.1 compilers.  User code like this will now hit compiler error C2440.   

Description:

This is incorrect code.  By definition const_cast can only be used to remove/add a cv qualifier. Any other use of it is incorrect. 

Customer Workaround:

Customer workaround it to concatenate use of const_cast with one of our other casts that can down cast (dynamic_cast, static_cast or __try_cast). 

Rationale:

The C++ Standard indicates that const_cast should be used to add or remove a const volatile qualifier; to allow it to behave differently  special case on managed types was wrong. 

7. Compiler disallows forward declaration of a managed enum

Affected User Scenario:

Declaring and not defining a managed enum (/clr or /clr:oldSyntax) will give a compiler error.  Code written for the VC7.0 and VC7.1 compilers will break. 

Description:

This used to compile in VC7.0 and VC7.1, but was not guaranteed to work correctly.  The problem is the compiler can't correctly identify the underlying type of the enum. 

Customer Workaround:

Customer should always define his managed enums at declaration 

Rationale:

Managed enums can have different underlying types.  We have no syntax for specifying an underlying type in an enum declaration; also the C++ Standard does not allow enum declarations. 

8. Switch removal: /YX

Affected User Scenario:

Users used this switch to generate automatic pre-compiled headers support for their code.  It was used by default from the IDE. 

Description:

We have other switches that the user can use to add pre-compiled headers support that are better. 

Customer Workaround:

Customer can use /Yc and /Yu for pre compiled headers support. 

Rationale:

This switch sometimes behaved incorrectly.  We prefer customers use /Yc and /Yu which give the user more control. 

9. Switch removal: Optimizations /Oa, /Op and /Ow

Affected User Scenario:

Users will need to remove these from their projects. 

Description:

These switches are both replaced by others or not needed anymore 

Customer Workaround:

Customer can use the /fp switches for floating point optimizations. 

Rationale:

Compiler options /Oa and /Ow usually led people to generate bad code and /Op was replaced by the better /fp switches; these provide the user with better control. 

10. Switch removal: /ML and /MLd

Affected User Scenario:

Users that depended on statically linking to the single threaded CRT. 

Description:

There is no single threaded CRT anymore 

Customer Workaround:

Customer can just use /MT and /MTd respectively 

Rationale:

We stopped making a single threaded C Runtime Library (CRT) and thus we do not need this compiler option anymore. 

11. Switch removal: /G3 - /G7, /GB, /Gf, /GD, /GM

Affected User Scenario:

Users will need to remove these from their projects. 

Description:

The processor specific optimization switches can be replaced by our /OX family of switches. 

Customer Workaround:

Customer can achieve the same functionality using our /OX family of optimization switches. 

Rationale:

Compiler options /G3 - /G7 targeted specific processors, most of which are no longer mass marketed.  The user can achieve the same optimizations with our Ox compiler options.  For 64 bit development, we added a new optimization switch: /Favor:[ALL|AMD64|EM64T].  Compiler option /Gf enabled string pooling but used writeable memory which is dangerous, /GF achieves the same functionality in safer readonly memory.  Compiler option /GD's functionality can be achieved with our other optimizaton options; we do not need specific DLL optimizations.  Compiler options /GM and /GB are not needed anymore. 

12. Switch conflict: /clr and /MT

Affected User Scenario:

Users will need to replace /MT with /MD for their code targeting .NET 

Description:

There is no support in the CRT for statically linking managed applications.  

Customer Workaround:

Customer needs to change /MT to /MD and link dynamically to the CRT. 

Rationale:

There is no support in the C Runtime Library to statically link to a managed application.  All managed applications have to be dynamically linked; thus the reason to make the two compiler options conflict. 

13. Switch change: /GS turned on by default.

Affected User Scenario:

Users now get buffer overflow checks by default in their code. 

Description:

This is a good thing.  If you are getting errors with this switch it is very likely that the user code has a security flaw. 

Customer Workaround:

Customer can turn the option of with /GS- 

Rationale:

We want our users to always benefit from the security checks /GS provides. 

14. Switch change: /Zc:wchar_t turned on by default

Affected User Scenario:

This will break binary compatibilty when client code is linked with libraries that were compiled without Zc:wchar_t 

Description:

This is Standard C++ behavior: A wchar_t variable will default to a built in type instead of a short unsigned integer. 

Customer Workaround:

Customer can use newly introduced compiler switch /Zc:wchar_t- to revert to the old non-standard behavior. 

Rationale:

This compiler option was introduced to correct a conformance discrepancy we shipped with once and still give users a way to revert to the old behavior.  We want our users code to be conformant by default. 

15. Switch change: /Zc:forScope turned on by default

Affected User Scenario:

Code bases that depend on usage of the for scope declared variable after block scope has ended will break fail to compile. 

Description:

This is Standard C++ behavior: A for scope declared variable will not persist outside the for block scope. 

Customer Workaround:

Customer can use newly introduced compiler switch /Zc:forScope- to revert to the old non-standard behavior. 

Rationale:

This compiler option was introduced to correct a conformance discrepancy we shipped with once and still give users a way to revert to the old behavior.  We want our users code to be conformant by default.

16. Enforcing parameter checking for vc attributes

Affected User Scenario:

User code that passes named attributes to the attribute constructor in quotes when type is not a string and without quotes when type is a string will stop compiling 

Description:

Previously all compiler attributes were parsed as strings, hence either [threading(“apartment”)] and [threading(apartment)] worked because the compiler will put in the missing quotes. In passing named arguments to attributes, the type is enforced always. 

Customer Workaround:

The compiler displays a hint that you should try the quoted or unquoted version of the parameter in this scenario.  User will need to fix their code. 

Rationale:

We enhanced our attribute support by adding parameter checking validation.  This way our customers will not run into unexpected behavior due to incorrect arguments to an attribute constructor. 

17. uuid attribute can no longer target managed types

Affected User Scenario:

Old syntax code that uses the uuid attribute on managed targets 

Description:

We used to map the uuid attribute to the BCL's GuidAttribute when we parsed it on managed type targets. 

Customer Workaround:

Customer should use the BCL's GuidAttribute attribute when targeting managed types 

Rationale:

The .NET Framework provides a UUID attribute to be used with managed targets.  We want our users to use this and not change the code for them behind the scenes. 

18. The syntax changed for passing CLI arrays to custom attributes

Affected User Scenario:

Old syntax code that uses user defined custom attributes that take CLI arrays in the contructor needs to be updated. 

Description:

The type of the array is not deduced anymore from the aggregate initialization list.  We now need to specify the type along with the initializer list. 

Customer Workaround:

Customer needs to explicitly specify the type of the array with the aggreagate initialization as so: [Attr(new String*[] {"a", "B"}] 

Rationale:

The compiler could not always correctly deduce the array type from the aggregate initialization list: { 1, 'c', 1i64 }, what is the array type here?  Thus we wanted the user to be more specific and use a syntax similar to the syntax we added for aggregate initialization of CLI arrays in the new syntax. 

19. Attribute look up changes - compiler will only find non-suffixed attribute name inside attribute block

Affected User Scenario:

Code that referenced the attribute name without the suffix outside an attribute block will fail to compile 

Description:

Compiler will only consider the name without its suffix inside an attribute code block.  Elsewhere the class name should follow normal C++ look up rules and should be referenced with its full name 

Customer Workaround:

Users need to append the Attribute suffix to their references and conform to C++ look up rules to fix their code 

Rationale:

We did this to resolve ambiguous look up cases between non attribute managed classes and attribute managed classes.  For example if there exists ref class A and ref class AAttribute : System::Attribute what type is A ^a? 

20. Compiler will not inject a default type int in declarations missing a type

Affected User Scenario:

Code out there that was missing the type in a declaration will no longer default to int and will err. 

Description:

This is Standard C++.  The compiler should not be assuming a default type of int in any declaration: whether a function or a variable. 

Customer Workaround:

Customer should fix his code or disable the warning that is treated as an error by default (C4430) 

Rationale:

Standard C++ does not support a default int.  We also wanted to make this change because it is very likely that the user did not intend a return type of int and just forgot to write the desired return type. 

21. Valuetypes no longer have a default constructor emitted – this can cause type initializers to run at different points

Affected User Scenario:

User code that depended on a type initializer to run before instantiation of an object of its type might behave incorrectly 

Description:

In previous versions of our compiler, we emitted a default constructor for value types and this caused the type initializer for the class to run before any objects of the class type get created; it would also run before any static data gets referenced.  Now, we only guarantee the latter since there is no longer a default constructor being emitted. 

Customer Workaround:

Customer needs to conform their code to the new rules for when the type initializer is guaranteed to run, or force it to run explicitly. 

Rationale:

There were two reasons we took into account for not providing a default constructor for value types: the CLR could not guarantee that they would always call it (thus making code erratic or inconsistent at runtime) and a performance increase. 

22. Native types are private by default in a managed compilation

Affected User Scenario:

Users that depended on these being public by default. 

Description:

The compiler will assume private on native types that did not specify a class accessibility modifier.  In 7.0 it would behave the same way.  The 7.1 compiler would assume public which led to some unexpected and negative side effects. 

Customer Workaround:

User will have to explicitly put a public accessibility specifier in the native class declaration if they want it to be public. 

Rationale:

We had different reasons to go back to the 7.0 behavior on native types in a managed compilation.  When an assembly was imported namespaces where polluted with irrelevant native types that were brought in.  This caused interoperability problems with other languages like VB.NET that were case insensitive and thus there were name conflicts.  We think that native types used in an assembly should be left as an implementation detail and thus made private by default.  If the user desires the contrary behavior, he can always use the public accessibility class modifier.   

23. Switch change: The /clr switch will now compile new syntax C++ code and not Managed Extensions for C++ syntax

Affected User Scenario:

Code written for Managed Extensions for C++ that is harnessed to compile with the /clr switch 

Description:

We changed the meaning of the /clr switch to now default to our new C++ syntax to target the CLR instead of the old one shipped with previous versions of the compiler 

Customer Workaround:

Change /clr to /clr:oldSyntax to compile code written with Managed Extensions for C++ 

Rationale:

The new syntax language is the way to go when targetting the .NET platform using C++.  We want users to get the benefits from this new rich experience by default. 

24. Switch change: C compilands are not supported with /clr

Affected User Scenario:

Users that compiled files with .c extension or with command line options /TC or /Tc with any switch from the /clr family will see an error. 

Description:

The C language does not support the CLR 

Customer Workaround:

User can change the file extension to .cpp|.cxx or compile with the /TP or /Tp command line options 

Rationale:

We provide a C++ language to target the .NET platform, not a C language, thus the C language does not support the CLR.  With this in mind we made that compilation scenario invalid.

About Chris Maunder



Site Admin
Editor
Site Builder
Chris is the Co-founder, Administrator, Architect, Chief Editor and Shameless Hack who wrote and runs CodeProject. He's been programming since 1988 while pretending to be, in various guises, an astrophysicist, mathematician, physicist, hydrologist, geomorphologist, defence intelligence researcher and then, when all that got a bit rough on the nerves, a web developer. He is a Microsoft Visual C++ MVP both globally and for Canada locally.

His programming experience includes C/C++, C#, MFC, ASP, ASP.NET, and far, far too much FORTRAN. He has worked on PocketPCs, AIX mainframes, Sun workstations, and a CRAY YMP C90 behemoth but finds notebooks take up less desk space.

He dodges, he weaves, and he never gets enough sleep. He is kind to small animals.

Chris was born and bred in Australia but is currently based in Toronto enjoying the weather. For relaxation he is into snowboarding, rock climbing, mountain biking, and storm chasing.

Click here to view Chris Maunder's online profile.

posted on 2005-12-29 15:07 夢在天涯 閱讀(820) 評論(0)  編輯 收藏 引用 所屬分類: CPlusPlus

公告

EMail:itech001#126.com

導航

統計

  • 隨筆 - 461
  • 文章 - 4
  • 評論 - 746
  • 引用 - 0

常用鏈接

隨筆分類

隨筆檔案

收藏夾

Blogs

c#(csharp)

C++(cpp)

Enlish

Forums(bbs)

My self

Often go

Useful Webs

Xml/Uml/html

搜索

  •  

積分與排名

  • 積分 - 1811982
  • 排名 - 5

最新評論

閱讀排行榜

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
              国产资源精品在线观看| 蜜臀a∨国产成人精品| 久久精品视频在线看| 欧美一区二区三区免费观看视频| 亚洲一级黄色av| 亚洲午夜久久久| 午夜精品理论片| 麻豆精品视频| 亚洲精品中文字幕有码专区| 国产精品99久久久久久久vr| 亚洲欧美999| 免费在线欧美黄色| 国产精品成人一区二区网站软件| 国产精品一区在线观看| 在线观看不卡| 亚洲综合视频1区| 浪潮色综合久久天堂| 亚洲精品久久| 欧美伊人久久大香线蕉综合69| 快射av在线播放一区| 欧美特黄一级| 在线观看视频一区| 亚洲女性喷水在线观看一区| 欧美gay视频激情| 亚洲一区在线播放| 欧美国产精品日韩| 国产最新精品精品你懂的| 日韩视频一区| 猫咪成人在线观看| 在线亚洲自拍| 欧美成人中文字幕| 一区二区视频免费在线观看| 亚洲免费视频在线观看| 欧美韩日一区| 久久精品国产96久久久香蕉| 国产精品久久久久久久午夜| 亚洲三级影院| 欧美成人国产| 久久精品国产99精品国产亚洲性色 | 久久精品国产亚洲a| 欧美激情视频一区二区三区不卡| 国产欧美一区二区白浆黑人| 一区二区三区四区蜜桃| 欧美www视频| 久久久精品网| 韩国成人理伦片免费播放| 午夜精品理论片| 在线一区观看| 国产精品成人午夜| 99在线热播精品免费| 亚洲国产国产亚洲一二三| 久久久久免费| 娇妻被交换粗又大又硬视频欧美| 欧美在线视频在线播放完整版免费观看| 亚洲精品免费在线播放| 欧美成人一区二区三区在线观看 | 国产精品99久久久久久久vr| 亚洲国产成人久久| 农村妇女精品| 亚洲免费成人av| 最新成人在线| 欧美理论在线| 亚洲夜间福利| 亚洲一区二区在| 国产日产高清欧美一区二区三区| 欧美在线视频免费观看| 久久国产精品99国产精| 国产主播精品在线| 久久久久久自在自线| 久久九九免费视频| 亚洲人在线视频| 亚洲狼人综合| 国产精品羞羞答答| 久久婷婷蜜乳一本欲蜜臀| 久久久亚洲人| 一区二区动漫| 性色av一区二区三区| 一区免费观看视频| 亚洲人成啪啪网站| 国产精品免费电影| 每日更新成人在线视频| 欧美激情无毛| 欧美一区二区私人影院日本 | 久久亚洲不卡| 99精品免费| 亚洲一区二区高清| 一区二区三区在线视频免费观看| 亚洲国产老妈| 国产精品一区二区在线观看不卡| 久久中文久久字幕| 久久激情久久| 另类专区欧美制服同性| 欧美成在线观看| 亚洲小说春色综合另类电影| 欧美在线视频在线播放完整版免费观看 | 国产精品日日摸夜夜摸av| 久久亚洲不卡| 欧美日韩国产黄| 久久网站免费| 国产精品福利在线观看网址| 麻豆精品在线播放| 国产精品理论片在线观看| 欧美大片va欧美在线播放| 欧美丝袜第一区| 欧美激情第3页| 国产一区二区三区在线观看视频| 亚洲精品一区二区网址| 在线观看日韩专区| 午夜视频在线观看一区| 亚洲永久字幕| 欧美伦理a级免费电影| 久久午夜电影网| 国产精品日韩专区| 亚洲毛片av| 日韩视频永久免费观看| 久久久精品日韩欧美| 久久激情婷婷| 国产精品一区二区久久久| 日韩小视频在线观看专区| 91久久精品一区二区别| 久久久综合精品| 久久久久久久综合狠狠综合| 国产精品乱码一区二区三区| 一本不卡影院| 亚洲综合视频一区| 欧美午夜在线观看| 99热在线精品观看| 艳妇臀荡乳欲伦亚洲一区| 免费精品99久久国产综合精品| 久久米奇亚洲| 国内精品久久久久久久影视麻豆| 亚洲综合日韩中文字幕v在线| 亚洲制服丝袜在线| 国产精品国产三级国产专区53| 日韩一二三区视频| 一本色道久久88亚洲综合88| 欧美久久电影| 日韩小视频在线观看专区| 99亚洲一区二区| 欧美性大战xxxxx久久久| 在线亚洲一区二区| 欧美一区在线直播| 国产亚洲精品一区二555| 欧美怡红院视频| 欧美aⅴ一区二区三区视频| 亚洲欧洲在线观看| 欧美日韩爆操| 亚洲男人av电影| 久久综合中文色婷婷| 亚洲国产精品综合| 欧美视频精品在线观看| 亚洲一区二三| 久热这里只精品99re8久| 最新国产成人在线观看| 亚洲综合成人在线| 亚洲小少妇裸体bbw| 性做久久久久久免费观看欧美| 国产精品一区二区三区久久久| 午夜精品久久久久久久蜜桃app| 久久久久久久久一区二区| 在线不卡a资源高清| 欧美日韩成人| 欧美资源在线| 亚洲片在线资源| 篠田优中文在线播放第一区| 红桃视频欧美| 欧美色道久久88综合亚洲精品| 午夜在线a亚洲v天堂网2018| 欧美69wwwcom| 亚洲欧美日韩精品在线| 在线免费观看一区二区三区| 欧美日本韩国在线| 欧美伊人精品成人久久综合97| 欧美激情一区二区三区不卡| 亚洲欧美美女| 亚洲欧洲午夜| 国模精品一区二区三区色天香| 欧美精品一区三区| 欧美在线视频网站| 中日韩高清电影网| 亚洲国产精品毛片| 久久视频一区| 亚洲一区二区三区四区中文| 亚洲高清不卡在线观看| 国产免费观看久久| 欧美日韩一二三区| 久久综合网色—综合色88| 亚洲宅男天堂在线观看无病毒| 亚洲国产专区校园欧美| 久久手机免费观看| 久久精品成人欧美大片古装| 在线一区二区三区四区五区| 亚洲第一在线综合在线| 国产亚洲激情在线| 国产精品网站在线观看| 欧美视频精品在线观看| 欧美日韩国产美女| 欧美成ee人免费视频| 久久免费国产| 久久久久88色偷偷免费|