我程序里面用到一个common模块 里面是一些要用的函数,在其他程序上用没问题,但是在这次的使用上就出现问题了
我首先把错误信息发下:
e:\c++\xmlser\common\commonfun.h(428) : error C2146: syntax error : missing ';' before identifier 'listctrl'
e:\c++\xmlser\common\commonfun.h(428) : error C2501: 'CListCtrl' : missing storage-class or type specifiers
e:\c++\xmlser\common\commonfun.h(428) : error C2501: 'listctrl' : missing storage-class or type specifiers
e:\c++\xmlser\common\commonfun.h(452) : error C2146: syntax error : missing ';' before identifier 'LoadSysStr'
e:\c++\xmlser\common\commonfun.h(452) : error C2501: 'CString' : missing storage-class or type specifiers
e:\c++\xmlser\common\commonfun.h(452) : fatal error C1004: unexpected end of file found
对应第一个错误的代码是:
struct SortData
{
     CListCtrl* listctrl;                 //CListCtrl控件指针就是这里啦!!
     int isub;        //l列号
     int seq;        //1为升序,0为降序
};
头文件包含在里面呀  怎么CListCtrl和CString都不能用了呢 ?

解决方案 »

  1.   

    CListCtrl 这个类没有定义或者声明一下,有时候也有可能前面有分号没有加导致错误的提示。
      

  2.   

    是不是没有#include "stdafx.h"呀?
      

  3.   

    stdafx文件默认生成时就包含了头文件的。
    //#if !defined(AFX_STDAFX_H__3A72B905_628E_468A_98BC_C4410C2F4756__INCLUDED_)
    #define AFX_STDAFX_H__3A72B905_628E_468A_98BC_C4410C2F4756__INCLUDED_#if _MSC_VER > 1000
    #pragma once
    #endif // _MSC_VER > 1000#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers#include <afxwin.h>         // MFC core and standard components
    #include <afxext.h>         // MFC extensions
    #include <afxdisp.h>        // MFC Automation classes
    #include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
    #ifndef _AFX_NO_AFXCMN_SUPPORT
    #include <afxcmn.h> // MFC support for Windows Common Controls
    #endif // _AFX_NO_AFXCMN_SUPPORT
    #include <afxcmn.h> // MFC support for Windows Common Controls
      

  4.   

    问题解决了   是编译环境设置的问题。。在VC的setting里选择c/c++选项 选择里面的Preprocessor 里面加上了 ./ 和./xml 就可以了