“unexpected #endif”这个错误应该怎么解决?谢谢。

pan_1107 2007-06-25 10:00:24
以下是我的代码中有问题的部分,请各位高人指点一下,急等中......
#include "StudentDlg.h"
#include "MainFrm.h"
#include "SearchDlg.h"
#ifdef _DEBUG
#include "stdafx.h"
#include "manage.h"
#include "StudentRecordset.h"
#include "LoginRecordset.h"
#include "LoginDlg.h"
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
......
...全文
1649 17 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
avcodec-decoder 2011-08-22
  • 打赏
  • 举报
回复
你的工程中导入的其他头文件,删除这个不是自己的头文件即可
bluesky12312388 2011-03-23
  • 打赏
  • 举报
回复
[Quote=引用 15 楼 zhang_475815 的回复:]

最后怎么解决的?
我也遇到一样的问题了
[/Quote]
简单地说就是#if #ifndef #ifdef #else 和你的#endif不匹配导致的,
只是空想家 2011-03-23
  • 打赏
  • 举报
回复
最后怎么解决的?
我也遇到一样的问题了
Avoid 2007-06-26
  • 打赏
  • 举报
回复
系统自己会在最后一行添加#endif,估计是被你删除了.
Avoid 2007-06-26
  • 打赏
  • 举报
回复
在你的头文件最后一行加上

#endif
agaric 2007-06-26
  • 打赏
  • 举报
回复
是你自己包含的某個頭文件里有誤。 而且一般來講,最后每個文件末尾給個空行。
pan_1107 2007-06-26
  • 打赏
  • 举报
回复
我把那些"#fi"和"#endif"都除去了,编译成功,但是我的程序编译通过后运行,修改数据库后,弹出对话框"参数不足,期待是 1.",我想问的就是这会是什么原因造成的,我的开发经验不足,所以有些不知所措,希望高手们能够加以指点.谢谢.
pan_1107 2007-06-26
  • 打赏
  • 举报
回复
问题照旧
Inhibitory 2007-06-26
  • 打赏
  • 举报
回复
#if !defined(AFX_MAINFRM_H__78B74327_EE99_4E5F_AFA7_74BEB509D438__INCLUDED_)
换成
#ifndef AFX_MAINFRM_H__78B74327_EE99_4E5F_AFA7_74BEB509D438__INCLUDED_
试试
pan_1107 2007-06-26
  • 打赏
  • 举报
回复
这是经过检查后最有可能出错的一个".h"文件,请大家帮我看看有没有错误,谢谢.
// MainFrm.h : interface of the CMainFrame class
//
/////////////////////////////////////////////////////////////////////////////

#include "ManageView.h"
#if !defined(AFX_MAINFRM_H__78B74327_EE99_4E5F_AFA7_74BEB509D438__INCLUDED_)
#define AFX_MAINFRM_H__78B74327_EE99_4E5F_AFA7_74BEB509D438__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CManageView;
class CMainFrame : public CFrameWnd
{
public : CManageView * m_ListView;

protected: // create from serialization only
CMainFrame();
DECLARE_DYNCREATE(CMainFrame)

// Attributes
public:

// Operations
public:

// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMainFrame)
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
//}}AFX_VIRTUAL

// Implementation
public:
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif

protected: // control bar embedded members
CStatusBar m_wndStatusBar;
CToolBar m_wndToolBar;

// Generated message map functions
protected:
//{{AFX_MSG(CMainFrame)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnStudentAdd();
afx_msg void OnStudentDelete();
afx_msg void OnStudentEdit();
afx_msg void OnStudentList();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_MAINFRM_H__78B74327_EE99_4E5F_AFA7_74BEB509D438__INCLUDED_)
  • 打赏
  • 举报
回复
}
#ifdef 之类的东西不匹配
星羽 2007-06-25
  • 打赏
  • 举报
回复
看看是不是

#include "StudentRecordset.h"
#include "LoginRecordset.h"
#include "LoginDlg.h"

里有问题
freshui 2007-06-25
  • 打赏
  • 举报
回复
hoho
从你的代码上看配对了
再找找, 可能不是这个文件中的错误
agaric 2007-06-25
  • 打赏
  • 举报
回复
字面上看 是#if #endif没有配对,自己仔细看看。
Inhibitory 2007-06-25
  • 打赏
  • 举报
回复
我一般用的是
#ifndef VVV_H_
#define VVV_H_
...
#endif
这样是没问题的.
哼哈荷叶 2007-06-25
  • 打赏
  • 举报
回复
不知道
pan_1107 2007-06-25
  • 打赏
  • 举报
回复
以下是代码的全部内容:
// MainFrm.cpp : implementation of the CMainFrame class
//
#include "StudentDlg.h"
#include "MainFrm.h"
#include "SearchDlg.h"
#ifdef _DEBUG
#include "stdafx.h"
#include "manage.h"
#include "StudentRecordset.h"
#include "LoginRecordset.h"
#include "LoginDlg.h"
#define new DEBUG_NEW
#undef THIS_FILE
#endif
static char THIS_FILE[] = __FILE__;


/////////////////////////////////////////////////////////////////////////////
// CMainFrame

IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)

BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
//{{AFX_MSG_MAP(CMainFrame)
ON_WM_CREATE()
ON_COMMAND(ID_Student_Add, OnStudentAdd)
ON_COMMAND(ID_Student_Delete, OnStudentDelete)
ON_COMMAND(ID_Student_Edit, OnStudentEdit)
ON_COMMAND(ID_Student_List, OnStudentList)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

static UINT indicators[] =
{
ID_SEPARATOR, // status line indicator
ID_INDICATOR_CAPS,
ID_INDICATOR_NUM,
ID_INDICATOR_SCRL,
};

/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction

CMainFrame::CMainFrame()
{
// TODO: add member initialization code here

}



int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;

if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}

if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}

// TODO: Delete these three lines if you don't want the toolbar to
// be dockable
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar);

return 0;
}

BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CFrameWnd::PreCreateWindow(cs) )
return FALSE;
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs

return TRUE;
}

/////////////////////////////////////////////////////////////////////////////
// CMainFrame diagnostics

#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
CFrameWnd::AssertValid();
}

void CMainFrame::Dump(CDumpContext& dc) const
{
CFrameWnd::Dump(dc);
}

#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers


void CMainFrame::OnStudentAdd()
{
// TODO: Add your command handler code here
CStudentDlg m_StudentDlg;
if(m_StudentDlg.DoModal()!=IDOK)
return;
CStudentRecordset m_StudentRecordset;
try
{
if(m_StudentRecordset.IsOpen())
m_StudentRecordset.Close();
m_StudentRecordset.m_strFilter.Format("Name='%s' order by Primary ASC",m_StudentDlg.m_Name.operator LPCTSTR());
m_StudentRecordset.Open(CRecordset::snapshot,NULL,CRecordset::none);
if(!m_StudentRecordset.IsBOF())
{m_StudentRecordset.Close();
AfxMessageBox("同名用户已经存在。");
return;
}
m_StudentRecordset.AddNew();
m_StudentRecordset.m_Phy=m_StudentDlg.m_Phy;
m_StudentRecordset.m_Chn=m_StudentDlg.m_Chn;
m_StudentRecordset.m_Class=m_StudentDlg.m_Class;
m_StudentRecordset.m_Eng=m_StudentDlg.m_Eng;
m_StudentRecordset.m_Grade=m_StudentDlg.m_Grade;
m_StudentRecordset.m_Maths=m_StudentDlg.m_Maths;
m_StudentRecordset.m_Name=m_StudentDlg.m_Name;
m_StudentRecordset.m_Num=m_StudentDlg.m_Num;
m_StudentRecordset.m_Sex=m_StudentDlg.m_Sex;
m_StudentRecordset.m_Chem=m_StudentDlg.m_Chem;
if(m_StudentRecordset.CanUpdate())
{m_StudentRecordset.Update();}
if(m_StudentRecordset.IsOpen())
m_StudentRecordset.Close();
}
catch(CDBException*e)
{e->ReportError();
return;
}
}
void CMainFrame::OnStudentDelete()
{
// TODO: Add your command handler code here

if(MessageBox("是否删除此记录?","删除确认",MB_YESNO|MB_ICONQUESTION)==IDYES)
{
m_ListView->DelCurStudent();
}
}

void CMainFrame::OnStudentEdit()
{
// TODO: Add your command handler code here
m_ListView->EditCurStudent();
}

void CMainFrame::OnStudentList()
{ CSearchDlg m_SearchDlg;
if(m_SearchDlg.DoModal()!=IDOK)
return;
m_ListView->ListUser(m_SearchDlg.m_Search);
// TODO: Add your command handler code here

}
/*** *eh.h - User include file for exception handling. * * Copyright (c) 1993-1997, Microsoft Corporation. All rights reserved. * *Purpose: * User include file for exception handling. * * [Public] * ****/ #if _MSC_VER > 1000 #pragma once #endif #ifndef _INC_EH #define _INC_EH #if !defined(_WIN32) && !defined(_MAC) #error ERROR: Only Mac or Win32 targets supported! #endif #ifdef _MSC_VER // Currently, all MS C compilers for Win32 platforms default to 8 byte // alignment. #pragma pack(push,8) #endif // _MSC_VER #ifndef __cplusplus #error "eh.h is only for C++!" #endif /* Define _CRTIMP */ #ifndef _CRTIMP #ifdef _DLL #define _CRTIMP __declspec(dllimport) #else /* ndef _DLL */ #define _CRTIMP #endif /* _DLL */ #endif /* _CRTIMP */ /* Define _CRTAPI1 (for compatibility with the NT SDK) */ #ifndef _CRTAPI1 #if _MSC_VER >= 800 && _M_IX86 >= 300 #define _CRTAPI1 __cdecl #else #define _CRTAPI1 #endif #endif typedef void (__cdecl *terminate_function)(); typedef void (__cdecl *unexpected_function)(); typedef void (__cdecl *terminate_handler)(); typedef void (__cdecl *unexpected_handler)(); #ifndef _MAC struct _EXCEPTION_POINTERS; typedef void (__cdecl *_se_translator_function)(unsigned int, struct _EXCEPTION_POINTERS*); #endif #if _MSC_VER >= 1200 _CRTIMP __declspec(noreturn) void __cdecl terminate(void); _CRTIMP __declspec(noreturn) void __cdecl unexpected(void); #else _CRTIMP void __cdecl terminate(void); _CRTIMP void __cdecl unexpected(void); #endif _CRTIMP terminate_function __cdecl set_terminate(terminate_function); _CRTIMP unexpected_function __cdecl set_unexpected(unexpected_function); #ifndef _MAC _CRTIMP _se_translator_function __cdecl _set_se_translator(_se_translator_function); #endif #ifdef _MSC_VER #pragma pack(pop) #endif // _MSC_VER #endif // _INC_EH

33,322

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 新手乐园
社区管理员
  • 新手乐园社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧