Visual Studio 2005 一些搬迁注意事项

 

 

 

Since I've been using Visual Studio.NET 2005 I have discovered a myriad of undocumented (or documented in such a way as to seem inoccuous) breaks in the compilation of most code.


Standard C - the CRT

I should start with the simplest and probably most common breaks that would effect you if you use C or C++ with the Visual C++ 8.0 (VC8) compiler. If you have used swprintf or any of its relations you will find your code no longer compiles, or it does and gives an odd warning. This is extremely dangerous as to make it more conforming they have added an extra parameter for the buffer size. All well and good, but you find most of the code you download of the Internet no longer compiles. Simply adding #define _CRT_NONSTDC_NO_DEPRECATE 1
won't make a difference. You need to add:
#define _CRT_NON_CONFORMING_SWPRINTFS

Make sure this all gets added as the first thing in the stdafx.h or in the pre-processor definitions in the project settings.

The _CRT_NONSTDC_NO_DEPRECATE will deal with the instances of other C runtime library code that has also changed. This is because Microsoft have replaced all of the functions that you will get all the warnings about with "secure" functions. This means that the function names are appended with _s.

Floating Point Operations

There are three options now:

  • fp:fast - The fastest implementation.
  • fp:precise - slower but more "precise".
  • fp:strict - the strictest implementation.

You have to make a choice - faster or more precise. I still haven't discovered how imprecise fp:fast is yet.

C++ Standard Template Library

You'll probably find that any code you use will fall over in some obscure and not so obscure instances, as well as being much slower. And that goes double for Debug builds.

So you need to add these to the top of your stdafx.h or your pre-processor definitions (or to your command line). To get up and running use:
#define _SECURE_SCL 0
#define _SCL_SECURE_NO_DEPRECATE
#define _HAS_ITERATOR_DEBUGGING 0

How to define these values.

The options to add these things:

  1. Add to your stdafx.h as plain preprocessor definitions. This option seems to be the most hit-and-miss.
  2. Add to your pre-processor definitions in your project settings. This is done with semi-colon separated values, eg,_SECURE_SCL=0
  3. Add it to your commandline. Do this in the project settings commandline tab. Add /D_SECURE_SL=0 for instance, you simply add /D then the preprocessor symbol without a space with an optional assignment.

In some instances one option may not work but one of the three will.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值