最近将编程环境升级到VS2008,结果很多原来正常编译的projects都出现了编译告警和错误。花了一周多时间熟悉下VS2008.,总体来看vs2008在64位编程、多核/多处理器编译、函数的安全性、c++模板的支持方面都有很多改进。但是在升迁到新的环境之前也有很多问题需要重新考虑了。
1。time_t在vs2003中默认是32位__time32_t,现在默认为__time_64_t了,如果要继续兼任原有代码必须在头文件的开始处增加如下语句
#ifndef _USE_32BIT_TIME_T
#define _USE_32BIT_TIME_T//use __time32_t
#endif
2.sprintf,memcpy之类的函数都会提示告警,要继续使用这些函数必须在定义宏
#define _CRT_SECURE_NO_DEPRECATE
#define _CRT_SECURE_NO_WARNINGS
3.编译时出现:无法打开vc90.pdb的错误。在MSDN上搜索了一下,解决办法是
http://msdn.microsoft.com/en-us/library/hk8k8k4h(VS.80).aspx原文贴在这里,主要是因为vs2008支持一在个solutions下多个不相互依赖的project的并行编译,当然前提是你的cpu是多核的或者有多个cpu。如果多个projects的output目录相同就会碰到同时写入vc90.pdb的问题。知道了原因就很好解决了。
Title: You may receive a "PRJ0008" or "C2471" or "C1083" or "D8022" or "LNK1103" or similar error message when you try to build a solution in Visual C++
Symptoms:
- D8022 : Cannot open 'RSP00000215921192.rsp'
- PRJ0008 : Could not delete file 'vc90.idb'.
- C1083 : Cannot open program database file 'vc90.pdb'
- C2471 : Cannot update program database 'vc90.pdb'
- LNK1103 : debugging information corrupt.
Cause:
This problem occurs when all of the following conditions are true:
- You have a solution with more than one project in it.
- Two or more of the projects are not dependent on each other.
- You have parallel builds enabled. (Tools -> Options: Projects and Solutions, Build and Run: "maximum number of parallel project builds" is set to a value greater than 1)
- You are building on a system with multiple CPUs (cores).
- Two or more of the non-dependent projects are configured to use the same Intermediate and/or Output directory.
- A specific race condition in mspdbsrv.exe remains uncorrected.
Resolution:
To resolve the problem do one or more of the following:
- Reconfigure the non-dependent projects to specify an Intermediate and Output directory that is different from one another, e.g. Output Directory = "$(SolutionDir)$(ProjectName)\$(ConfigurationName)", Intermediate Directory = "$(OutDir)".
- Adjust your solution's project dependencies (Project -> Project Dependencies...) so that each is dependent on another.
- Disable parallel builds.
- Add the "/onecpu" boot option to your boot.ini file.
- Change you BIOS settings to enable/use only one CPU.
- File a problem report with Microsoft Technical Support and keep bugging the *** out of them until they eventually fix mspdbsrv.