Visual Studio 2005 一些搬迁注意事项
2009-11-15 02:39
288 查看
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:
Add to your stdafx.h as plain preprocessor definitions. This option seems to be the most hit-and-miss.
Add to your pre-processor definitions in your project settings. This is done with semi-colon separated values, eg,_SECURE_SCL=0
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.
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:
Add to your stdafx.h as plain preprocessor definitions. This option seems to be the most hit-and-miss.
Add to your pre-processor definitions in your project settings. This is done with semi-colon separated values, eg,_SECURE_SCL=0
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.
相关文章推荐
- Visual Studio 2005结合Direct 9.0 SDK(Aug2007)时应该注意的事项
- 构建Visual Studio 2005 Team Foundation Server的注意事项
- visual studio 2005 和 sql server 2005 安装时需要注意的事项
- 使用Visual Studio 2005开发的注意事项
- Visual Studio 2005 Remote Debugger 远程调试器 注意事项
- JavaScript操作数字的时候一些注意事项
- Android ExpandableListView和ScrollView联用的一些注意事项
- AutoLayout的一些注意事项
- Ionic2使用百度地图和html5 geolocation的一些注意事项
- 在内部开发环境建立反向代理的一些注意事项
- Visual Studio 2010 MSDN Help Library文档位置、错误、重新安装及安装注意事项
- block的一些注意事项
- Linux上安装Zookeeper以及一些注意事项
- 视频录制的一些注意事项
- 维护Dpm服务器时的一些注意事项 推荐
- 多线程的一些注意事项
- ajax提交表单的一些注意事项:解释为什么return false却依然提交
- 网站制作中一些注意事项
- Fragment+ViewPager组合,一些必知的注意事项
- c语言的一些注意事项