Quantcast
Channel: 浏忙大爆炸
Viewing all articles
Browse latest Browse all 107

两个 Visual Studio 2008 SP1 问题

$
0
0

Visual C++ 2008 SP1 compiler error C1859

有一些工程,在编译好后再重新编译,会提示类似如下错误(Windows7下容易出现):

Error   1       fatal error C1859: 'release\\testproject.pch' unexpected precompiled header error, simply rerunning the compiler might fix this problem

这个就是 Visual C++ 2008 SP1 compiler error C1859 的问题,解决办法就是安装一个补丁包

除了安装上述安装包以后,还可以使用如下方式来修复该问题:

  • Disable /analyze (if enabled).
  • Invoke a clean build.
  • Reboot your machine.
  • Disable PCH files.

使用 std::copy 时的 C4996 警告

Visual C++ 2008 里如果把警告当成错误处理时进行编译,下面这个警告就会被当成错误,很扎眼,而你,则一定需要解决这个问题。

Warning 2       warning C4996: 'std::copy': Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use Visual C++ 'Checked Iterators'

这是在使用 Visual C++ 自带的标准库时,Visual C++ 的编译器会加强检查,标准库里的一些方法会认为在使用上是不安全的。Visual C++ 对此提出警告、不建议使用这些函数,并且 Windows 提供了一些其它以 _s 结尾的函数用来替代这些方法。std::copy 就是这个现象的重灾区。

如果是你自己的代码碰到这个问题,那很好解决,你只需要把这些函数替换成 Windows 提供的更安全的函数即可。但是,如果是你引用的第三方库的代码问题,而你又在 Visual Studio 里把安全级别设置成不允许有警告,这个时候,就只能通过定义一个 _SCL_SECURE_NO_WARNINGS 宏来解决此问题。

Copyright © 2014, 浏忙大爆炸. All rights reserved.
除非注明,浏忙大爆炸文章均为原创,转载请以链接形式标明本文地址。


Viewing all articles
Browse latest Browse all 107

Trending Articles