VS常见编译问题

1、error  C2065:  'Vector' : undeclared  indentifier  
   分析:  没有包含文件vector ,同时 加上命名空间: using  namespace  std;
   原因: 不能识别类,没有包含头文件;

2、error C2664: "outputDebugString ":  can not  covert  parameter ,from   "const  char * " to "LPCWSTR"
   error C2440:“initializing ”: Cannot  convert  from "Whar_t *" to "std ::basic _string <Elem_Traits_Ax>"
   原因:宽字符问题:
   解决方法: 右键点击项目名,将解决方案的ProPerties ---- General --- character  set  属性 
   改为:  use Muti- Byte   characteristic Set;
   
3、warning C4091: ignored  on left  of 'char' when  no  varible  is  declared;
  原因:定义写错了, char *  fdb = “SSS”;
   需要改为: char fdb[] = "sss";

4、"Building  MFC  application  with  /MD[id](CRT dll  version)"  require  MFC  shared  dll version.  Please  #define  _AFXDLL or dont  use /MD[d]
   修改方法: 再头文件中添加 #define_AFXDLL 即可

5、error C2653: 'IBPP' is not   a class  or  namespace  name ;
   error  C 2227: left of "->start " must point  to  class/union/generic  type
   error C4430:missing type specifier--int assumed. Note:C++  does not  support  default  --int 
   分析:都不能识IBPP这个类 
   解决: 添加头文件  “IBPP/ibpp.h”

6、error C2864: "BSIMOD: m_eleUseRepair: only  static const  intergral  data  members  can  be initialized within a class;
   原因:类中 只有静态全局变量才能使用是static 修改方法,将类中的初始化去掉;

7、error C2512:"TiXmlelement" no appropricate  default  constructor  available;
   原因:开源代码中,TiXmlElement 没有默认构造函数,所以,全局变量初始化后是正确的;但是作为成员是不行的。
   构造函数的初始化的执行顺序为:
   A、父类构造函数‘
   B、类成员构造函数
   C、初始化类表构造函数’
   D、本身的构造函数
   方法: 使用static  将成员全局化, 这样TiXmflElemennt 的成员 就不用默认构造函数;

8、Can not  add two Pointer
  原因:string 中对 “+”的重载不允许连续加。
   错误语句: OutputDebugString(_T(str) + "\t" + str908TxtIndex + "\t" + strMsg)
   改为:char str[0] = [0];
     itoa(i, str, 10);
     string strlog = str;
      strlog += "\t";
     strlog += str908TxtIndex;
     outPutDebugstring(_T(strlog.str())); 

9、fatel error C1004:  unexpected  end of file found;
   原因: 1、{}不匹配;
           2、#if 0 没有对应的#endif

10、ULONG_PTR、DWORD等类型不存在定义;
分析: 这些类型在winbase.h中使用了,但在#include winbase.h之前 必须先将windows.h 包含进来 ; 
解决方法:
换高版本vc , 只需加入 #include <windows.h> 即可

12、error C1220: warning treated as error: no object generated;
解决: VS项目属性--- C++--- ”Treat  Warning  as Errors“  选择NO
    同时,Warning Level 设置为Level 3;






猜你喜欢

转载自blog.csdn.net/yuqian123455/article/details/80544920
今日推荐