各位大哥,小弟刚学VC,为什么语法没错,编译时还有下面那么多错误:f:\downloads\项目\gpacalculator\gpacalculatordlg.h(21) : error C2062: type 'double' unexpected
f:\downloads\项目\gpacalculator\gpacalculatordlg.h(21) : error C2238: unexpected token(s) preceding ';'
f:\downloads\项目\gpacalculator\gpacalculatordlg.h(28) : error C2059: syntax error : '<class-head>'
f:\downloads\项目\gpacalculator\gpacalculatordlg.h(28) : error C2334: unexpected token(s) preceding '{'; skipping apparent function body
f:\downloads\项目\gpacalculator\gpacalculatordlg.h(32) : error C2501: 'stScore' : missing storage-class or type specifiers
f:\downloads\项目\gpacalculator\gpacalculatordlg.h(33) : error C2065: 'stScore' : undeclared identifier
f:\downloads\项目\gpacalculator\gpacalculatordlg.h(33) : error C2059: syntax error : '>'
f:\downloads\项目\gpacalculator\gpacalculatordlg.h(36) : error C2143: syntax error : missing ';' before '{'
f:\downloads\项目\gpacalculator\gpacalculatordlg.h(81) : error C2143: syntax error : missing ';' before '}'
F:\Downloads\项目\GPACalculator\GPACalculator.cpp(17) : error C2143: syntax error : missing ';' before '{'
F:\Downloads\项目\GPACalculator\GPACalculator.cpp(17) : error C2248: '_messageEntries' : cannot access private member declared in class 'CGPACalculatorApp'
        f:\downloads\项目\gpacalculator\gpacalculator.h(40) : see declaration of '_messageEntries'
F:\Downloads\项目\GPACalculator\GPACalculator.cpp(17) : error C2143: syntax error : missing ',' before '}'
F:\Downloads\项目\GPACalculator\GPACalculator.cpp(22) : error C2143: syntax error : missing ';' before '{'
F:\Downloads\项目\GPACalculator\GPACalculator.cpp(22) : error C2248: 'OnHelp' : cannot access protected member declared in class 'CWinApp'
        c:\program files\microsoft visual studio\vc98\mfc\include\afxwin.h(4174) : see declaration of 'OnHelp'
F:\Downloads\项目\GPACalculator\GPACalculator.cpp(22) : error C2143: syntax error : missing ',' before '}'
F:\Downloads\项目\GPACalculator\GPACalculator.cpp(23) : error C2143: syntax error : missing ';' before '{'
F:\Downloads\项目\GPACalculator\GPACalculator.cpp(23) : error C2143: syntax error : missing ',' before '}'
F:\Downloads\项目\GPACalculator\GPACalculator.cpp(29) : error C2143: syntax error : missing ';' before '{'
F:\Downloads\项目\GPACalculator\GPACalculator.cpp(32) : error C2143: syntax error : missing ';' before '}'
F:\Downloads\项目\GPACalculator\GPACalculator.cpp(43) : error C2143: syntax error : missing ';' before '{'
F:\Downloads\项目\GPACalculator\GPACalculator.cpp(61) : error C2143: syntax error : missing ';' before '{'
F:\Downloads\项目\GPACalculator\GPACalculator.cpp(64) : error C2143: syntax error : missing ';' before '}'
F:\Downloads\项目\GPACalculator\GPACalculator.cpp(66) : error C2143: syntax error : missing ';' before '{'
F:\Downloads\项目\GPACalculator\GPACalculator.cpp(69) : error C2143: syntax error : missing ';' before '}'
F:\Downloads\项目\GPACalculator\GPACalculator.cpp(74) : error C2143: syntax error : missing ';' before '}'
F:\Downloads\项目\GPACalculator\GPACalculator.cpp(75) : error C2143: syntax error : missing ';' before '}'
F:\Downloads\项目\GPACalculator\GPACalculator.cpp(75) : fatal error C1001: INTERNAL COMPILER ERROR
        (compiler file 'Y?, line 1) 
         Please choose the Technical Support command on the Visual C++ 
         Help menu, or open the Technical Support help file for more information
        error count exceeds 100; stopping compilation
Generating Code...
执行 cl.exe 时出错.

解决方案 »

  1.   

    StdAfx.h头文件代码如下:
    #if !defined(AFX_STDAFX_H__82C3131E_0876_401A_BB80_CB7C0F444AD1__INCLUDED_)
    #define AFX_STDAFX_H__82C3131E_0876_401A_BB80_CB7C0F444AD1__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
    #include <afxtempl.h>
    #ifndef _AFX_NO_AFXCMN_SUPPORT没有定义什么宏,网上查了下,说什么要先引用windows.h,不知道是不是这样?
      

  2.   

    没有定义什么宏,网上查了下,说什么要先引用windows.h,不知道是不是这样? 
    ===============
    又不是SDK程序,不用windows.h的,将提示出错的代码贴出来看看吧
      

  3.   

    加上以后就这个错误:c:\program files\microsoft visual studio\vc98\mfc\include\afxv_w32.h(14) : fatal error C1189: #error :  WINDOWS.H already included.  MFC apps must not #include <windows.h>
    执行 cl.exe 时出错.
      

  4.   

    贴代码出来看看吧,要不然谁都说不清,另外上面已经说了不用加windows.h了,MFC程序自己已经加了
      

  5.   

    它不是有提示吗?
    f:\downloads\项目\gpacalculator\gpacalculatordlg.h(21) : error C2062: type 'double' unexpected 
    ========
    而且很像是头文件出错影响了别的地方
      

  6.   

    GPACalculator.h代码:
    #if !defined(AFX_GPACALCULATOR_H__AF79C9CF_D70F_40AD_AB9D_2D00D91CD702__INCLUDED_)
    #define AFX_GPACALCULATOR_H__AF79C9CF_D70F_40AD_AB9D_2D00D91CD702__INCLUDED_#if _MSC_VER > 1000
    #pragma once
    #endif // _MSC_VER > 1000#ifndef __AFXWIN_H__
    #error include 'stdafx.h' before including this file for PCH
    #endif#include "resource.h" // main symbols/////////////////////////////////////////////////////////////////////////////
    // CGPACalculatorApp:
    // See GPACalculator.cpp for the implementation of this class
    //class CGPACalculatorApp : public CWinApp
    {
    public:
    CGPACalculatorApp();// Overrides
    // ClassWizard generated virtual function overrides
    //{{AFX_VIRTUAL(CGPACalculatorApp)
    public:
    virtual BOOL InitInstance();
    //}}AFX_VIRTUAL// Implementation //{{AFX_MSG(CGPACalculatorApp)
    // NOTE - the ClassWizard will add and remove member functions here.
    //    DO NOT EDIT what you see in these blocks of generated code !
    //}}AFX_MSG
    DECLARE_MESSAGE_MAP()
    };
    GPACalculator.cpp代码:
    #include "stdafx.h"
    #include "GPACalculator.h"
    #include "GPACalculatorDlg.h"#ifdef _DEBUG
    #define new DEBUG_NEW
    #undef THIS_FILE
    static char THIS_FILE[] = __FILE__;
    #endif/////////////////////////////////////////////////////////////////////////////
    // CGPACalculatorAppBEGIN_MESSAGE_MAP(CGPACalculatorApp, CWinApp)
    //{{AFX_MSG_MAP(CGPACalculatorApp)
    // NOTE - the ClassWizard will add and remove mapping macros here.
    //    DO NOT EDIT what you see in these blocks of generated code!
    //}}AFX_MSG
    ON_COMMAND(ID_HELP, CWinApp::OnHelp)
    END_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////
    // CGPACalculatorApp constructionCGPACalculatorApp::CGPACalculatorApp()
    {
    // TODO: add construction code here,
    // Place all significant initialization in InitInstance
    }/////////////////////////////////////////////////////////////////////////////
    // The one and only CGPACalculatorApp objectCGPACalculatorApp theApp;/////////////////////////////////////////////////////////////////////////////
    // CGPACalculatorApp initializationBOOL CGPACalculatorApp::InitInstance()
    {
    AfxEnableControlContainer(); // Standard initialization
    // If you are not using these features and wish to reduce the size
    //  of your final executable, you should remove from the following
    //  the specific initialization routines you do not need.#ifdef _AFXDLL
    Enable3dControls(); // Call this when using MFC in a shared DLL
    #else
    Enable3dControlsStatic(); // Call this when linking to MFC statically
    #endif CGPACalculatorDlg dlg;
    m_pMainWnd = &dlg;
    int nResponse = dlg.DoModal();
    if (nResponse == IDOK)
    {
    // TODO: Place code here to handle when the dialog is
    //  dismissed with OK
    }
    else if (nResponse == IDCANCEL)
    {
    // TODO: Place code here to handle when the dialog is
    //  dismissed with Cancel
    } // Since the dialog has been closed, return FALSE so that we exit the
    //  application, rather than start the application's message pump.
    return FALSE;
    }
      

  7.   

    GPACalculatorDlg.h代码:#if !defined(AFX_GPACALCULATORDLG_H__611B7114_4F45_47C3_862A_D1A1930CFFE3__INCLUDED_)
    #define AFX_GPACALCULATORDLG_H__611B7114_4F45_47C3_862A_D1A1930CFFE3__INCLUDED_#if _MSC_VER > 1000
    #pragma once
    #endif // _MSC_VER > 1000/////////////////////////////////////////////////////////////////////////////
    // CGPACalculatorDlg dialogclass CGPACalculatorDlg : public CDialog
    {
    // Construction
    public:
    CGPACalculatorDlg(CWnd* pParent = NULL); // standard constructorPrivate:
    double GetSDPoint (double dPoint);
    void SpliterString (CString str,double &a,double &b);
    void GatherData ();
    void ChangeType (int nType);
    void SetEditRead(bool bReadOnly);
    Private:
    typedef struct stScore
    {
    double dOPoint;//原始分
    double dSPoint;//标准分
    double dNum;//学分
    }stScore;
    CArray<stScore,stScore&> arScore;
    // Dialog Data
    //{{AFX_DATA(CGPACalculatorDlg)
    enum { IDD = IDD_GPACALCULATOR_DIALOG };
    CString m_sPathName;
    double m_dS1;
    double m_dS2;
    double m_dS3;
    double m_dS4;
    double m_dS5;
    double m_dS6;
    double m_dS7;
    double m_dO1;
    double m_dO2;
    double m_dO3;
    double m_dO4;
    double m_dO5;
    double m_dO6;
    double m_dO7;
    double m_dO8;
    CString m_strAverage;
    CString m_strGPA;
    double m_dTotal;
    CString m_cmbStandard;
    CString m_ListScore;
    //}}AFX_DATA // ClassWizard generated virtual function overrides
    //{{AFX_VIRTUAL(CGPACalculatorDlg)
    protected:
    virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
    //}}AFX_VIRTUAL// Implementation
    protected:
    HICON m_hIcon; // Generated message map functions
    //{{AFX_MSG(CGPACalculatorDlg)
    virtual BOOL OnInitDialog();
    afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
    afx_msg void OnPaint();
    afx_msg HCURSOR OnQueryDragIcon();
    afx_msg void OnSelchangeComboStandard();
    afx_msg void OnButtonOpen();
    afx_msg void OnButtonOk();
    //}}AFX_MSG
    DECLARE_MESSAGE_MAP()
    };
      

  8.   

    GPACalculatorDlg.cpp代码:
    #include "stdafx.h"
    #include "GPACalculator.h"
    #include "GPACalculatorDlg.h"#ifdef _DEBUG
    #define new DEBUG_NEW
    #undef THIS_FILE
    static char THIS_FILE[] = __FILE__;
    #endif/////////////////////////////////////////////////////////////////////////////
    // CAboutDlg dialog used for App Aboutclass CAboutDlg : public CDialog
    {
    public:
    CAboutDlg();// Dialog Data
    //{{AFX_DATA(CAboutDlg)
    enum { IDD = IDD_ABOUTBOX };
    //}}AFX_DATA // ClassWizard generated virtual function overrides
    //{{AFX_VIRTUAL(CAboutDlg)
    protected:
    virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
    //}}AFX_VIRTUAL// Implementation
    protected:
    //{{AFX_MSG(CAboutDlg)
    //}}AFX_MSG
    DECLARE_MESSAGE_MAP()
    };CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
    {
    //{{AFX_DATA_INIT(CAboutDlg)
    //}}AFX_DATA_INIT
    }void CAboutDlg::DoDataExchange(CDataExchange* pDX)
    {
    CDialog::DoDataExchange(pDX);
    //{{AFX_DATA_MAP(CAboutDlg)
    //}}AFX_DATA_MAP
    }BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
    //{{AFX_MSG_MAP(CAboutDlg)
    // No message handlers
    //}}AFX_MSG_MAP
    END_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////
    // CGPACalculatorDlg dialogCGPACalculatorDlg::CGPACalculatorDlg(CWnd* pParent /*=NULL*/)
    : CDialog(CGPACalculatorDlg::IDD, pParent)
    {
    //{{AFX_DATA_INIT(CGPACalculatorDlg)
    m_sPathName = _T("");
    m_dS1 = 0.0;
    m_dS2 = 0.0;
    m_dS3 = 0.0;
    m_dS4 = 0.0;
    m_dS5 = 0.0;
    m_dS6 = 0.0;
    m_dS7 = 0.0;
    m_dO1 = 0.0;
    m_dO2 = 0.0;
    m_dO3 = 0.0;
    m_dO4 = 0.0;
    m_dO5 = 0.0;
    m_dO6 = 0.0;
    m_dO7 = 0.0;
    m_dO8 = 0.0;
    m_strAverage = _T("");
    m_strGPA = _T("");
    m_dTotal = 0.0;
    m_cmbStandard = _T("");
    m_ListScore = _T("");
    //}}AFX_DATA_INIT
    // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
    m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
    }void CGPACalculatorDlg::DoDataExchange(CDataExchange* pDX)
    {
    CDialog::DoDataExchange(pDX);
    //{{AFX_DATA_MAP(CGPACalculatorDlg)
    DDX_Text(pDX, IDC_EDIT_PATHNAME, m_sPathName);
    DDX_Text(pDX, IDC_EDIT_S1, m_dS1);
    DDX_Text(pDX, IDC_EDIT_S2, m_dS2);
    DDX_Text(pDX, IDC_EDIT_S3, m_dS3);
    DDX_Text(pDX, IDC_EDIT_S4, m_dS4);
    DDX_Text(pDX, IDC_EDIT_S5, m_dS5);
    DDX_Text(pDX, IDC_EDIT_S6, m_dS6);
    DDX_Text(pDX, IDC_EDIT_S7, m_dS7);
    DDX_Text(pDX, IDC_EDIT_O1, m_dO1);
    DDX_Text(pDX, IDC_EDIT_O2, m_dO2);
    DDX_Text(pDX, IDC_EDIT_O3, m_dO3);
    DDX_Text(pDX, IDC_EDIT_O4, m_dO4);
    DDX_Text(pDX, IDC_EDIT_O5, m_dO5);
    DDX_Text(pDX, IDC_EDIT_O6, m_dO6);
    DDX_Text(pDX, IDC_EDIT_O7, m_dO7);
    DDX_Text(pDX, IDC_EDIT_O8, m_dO8);
    DDX_Text(pDX, IDC_EDIT_AVERAGE, m_strAverage);
    DDX_Text(pDX, IDC_EDIT_GPA, m_strGPA);
    DDX_Text(pDX, IDC_EDIT_TOTAL, m_dTotal);
    DDX_CBString(pDX, IDC_COMBO_STANDARD, m_cmbStandard);
    DDX_LBString(pDX, IDC_LIST_SCORE, m_ListScore);
    //}}AFX_DATA_MAP
    }BEGIN_MESSAGE_MAP(CGPACalculatorDlg, CDialog)
    //{{AFX_MSG_MAP(CGPACalculatorDlg)
    ON_WM_SYSCOMMAND()
    ON_WM_PAINT()
    ON_WM_QUERYDRAGICON()
    ON_CBN_SELCHANGE(IDC_COMBO_STANDARD, OnSelchangeComboStandard)
    ON_BN_CLICKED(IDC_BUTTON_OPEN, OnButtonOpen)
    ON_BN_CLICKED(IDC_BUTTON_OK, OnButtonOk)
    //}}AFX_MSG_MAP
    END_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////
    // CGPACalculatorDlg message handlers
      

  9.   

    发现了好多个“Private”,P应小写。
      

  10.   

    比如:
    Private: 
    double GetSDPoint (double dPoint); 
    void SpliterString (CString str,double &a,double &b); 
    void GatherData (); 
    void ChangeType (int nType); 
    void SetEditRead(bool bReadOnly); 
    Private: 
    typedef struct stScore 

    double dOPoint;//原始分 
    double dSPoint;//标准分 
    double dNum;//学分 
    }stScore; 
      

  11.   

    晕,怎么只能回复3次啊,还有代码没帖了,谢谢大家了,没有认识的朋友懂VC啊.第一次在CSDN发贴,这里的朋友真热心^-^
      

  12.   

    写代码最好完成一点,编译一点,还要全部写完了,一起编。:)
    VC可以一次只编译一个CPP文件的。
      

  13.   

    谢谢steedhorse,我改过来了,可是还是这样!
      

  14.   

    唉,真是郁闷,看起来全大多是些自动生成的东西,却这么多错误。
    如果代码不是秘密,可以打个包给偶发一份吗?偶明天到了公司帮你用VC打开看看。[email protected]
    如果可以,打包的时候,别忘了删掉debug和release目录,还有.ncb文件,这几个都是巨大的,而且没用。
      

  15.   

    .obj,.exe,.lib,.dll……一般你只管把所有的debug和release目录都删掉就可以了。还有那个巨大的.ncb,呵呵。
      

  16.   

    steedhorse,太谢谢你了!我打包发给你,麻烦你了^-^