编译和警告

来源:互联网 发布:linux如何搜索文件夹 编辑:程序博客网 时间:2024/05/17 03:08

排出警告

#if defined(_MSC_VER)  &&  _MSC_VER >= 1310
# pragma warning( disable: 4996 )     // disable fopen deprecation warning
#endif


1:     Command line warning D9035 : option 'Wp64' has been deprecated and will be removed in a future release

原因:
vs2008不再建议使用/wp64检测64兼容问题,因为可以直接在32位OS上交叉编译为64位代码(vs2005也可以)。vs2008建议直接使用该方法检测64位兼容性问题。该选项被设置为“不推荐”有个原因是它会导致某些template库发生许多无效的warning。
解决办法:
Project property / c/c++ Detect 64 bit Portability Issues设为No。

 

2:warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss

文件中某些地方用到的空格不是Unicode的.


3:如果有不想出现的警告(知道它们没有危害),可以去除它们。

project -> property -> configuration properties -> c/c++ -> Advanced -> disable specific warnings

 

4:fatal error C1010: unexpected end of file while looking for precompiled header directive

解决方法:

1、如果发生错误的文件是由其他的C代码文件添加进入当前工程而引起的,则Alt+F7进入当前工程的 Settings,选择C/C++选项卡,从Category组合框中选中Precompiled Headers,选择Not Using Precompiled headers。确定。

2、在文件开头添加:
#include "stdafx.h"

  对预编译头文件说明如下:  
   
  所谓头文件预编译,就是把一个工程(Project)中使用的一些MFC标准头文件(如Windows.H、Afxwin.H)预先编译,以后该工程编译时,不再编译这部分头文件,仅仅使用预编译的结果。这样可以加快编译速度,节省时间。  
   
  预编译头文件通过编译stdafx.cpp生成,以工程名命名,由于预编译的头文件的后缀是“pch”,所以编译结果文件是projectname.pch。  
   
  编译器通过一个头文件stdafx.h来使用预编译头文件。stdafx.h这个头文件名是可以在project的编译设置里指定的。编译器认为,所有在指令#include   "stdafx.h"前的代码都是预编译的,它跳过#include  "stdafx.   h"指令,使用projectname.pch编译这条指令之后的所有代码。  
   
  因此,所有的CPP实现文件第一条语句都是:#include   "stdafx.h"。   

原创粉丝点击