新手 用C++作了一个贪吃蛇程序 最后编译时有错 但是我看不懂哪里错了 哪位帮忙看一下
c:\users\administrator\desktop\snake\snakegame.h(43):errorC2061:syntaxerror:identifie...
c:\users\administrator\desktop\snake\snakegame.h(43) : error C2061: syntax error : identifier 'UNIT'
c:\users\administrator\desktop\snake\snakegame.h(44) : error C2501: 'DECLARE_MESSAGE_MAP' : missing storage-class or type specifiers
SnakeDlg.cpp
c:\users\administrator\desktop\snake\snakegame.h(43) : error C2061: syntax error : identifier 'UNIT'
c:\users\administrator\desktop\snake\snakegame.h(44) : error C2501: 'DECLARE_MESSAGE_MAP' : missing storage-class or type specifiers
SnakeGame.cpp
c:\users\administrator\desktop\snake\snakegame.h(43) : error C2061: syntax error : identifier 'UNIT'
c:\users\administrator\desktop\snake\snakegame.h(44) : error C2501: 'DECLARE_MESSAGE_MAP' : missing storage-class or type specifiers
C:\Users\Administrator\Desktop\Snake\SnakeGame.cpp(32) : error C2509: '_GetBaseMessageMap' : member function not declared in 'CSnakeGame'
c:\users\administrator\desktop\snake\snakegame.h(20) : see declaration of 'CSnakeGame'
C:\Users\Administrator\Desktop\Snake\SnakeGame.cpp(32) : error C2509: 'GetMessageMap' : member function not declared in 'CSnakeGame'
c:\users\administrator\desktop\snake\snakegame.h(20) : see declaration of 'CSnakeGame'
C:\Users\Administrator\Desktop\Snake\SnakeGame.cpp(32) : warning C4273: 'protected: static struct AFX_MSGMAP const CWnd::messageMap' : inconsistent dll linkage. dllexport assumed.
C:\Users\Administrator\Desktop\Snake\SnakeGame.cpp(32) : error C2491: 'CSnakeGame::CWnd::messageMap' : definition of dllimport static data member not allowed
C:\Users\Administrator\Desktop\Snake\SnakeGame.cpp(94) : error C2556: 'void __thiscall CSnakeGame::OnPaint(void)' : overloaded function differs only by return type from 'int __thiscall CSnakeGame::OnPaint(void)'
c:\users\administrator\desktop\snake\snakegame.h(41) : see declaration of 'OnPaint'
C:\Users\Administrator\Desktop\Snake\SnakeGame.cpp(94) : error C2371: 'OnPaint' : redefinition; different basic types
c:\users\administrator\desktop\snake\snakegame.h(41) : see declaration of 'OnPaint'
C:\Users\Administrator\Desktop\Snake\SnakeGame.cpp(199) : fatal error C1903: unable to recover from previous error(s); stopping compilation
Generating Code...
Error executing cl.exe. 展开
c:\users\administrator\desktop\snake\snakegame.h(44) : error C2501: 'DECLARE_MESSAGE_MAP' : missing storage-class or type specifiers
SnakeDlg.cpp
c:\users\administrator\desktop\snake\snakegame.h(43) : error C2061: syntax error : identifier 'UNIT'
c:\users\administrator\desktop\snake\snakegame.h(44) : error C2501: 'DECLARE_MESSAGE_MAP' : missing storage-class or type specifiers
SnakeGame.cpp
c:\users\administrator\desktop\snake\snakegame.h(43) : error C2061: syntax error : identifier 'UNIT'
c:\users\administrator\desktop\snake\snakegame.h(44) : error C2501: 'DECLARE_MESSAGE_MAP' : missing storage-class or type specifiers
C:\Users\Administrator\Desktop\Snake\SnakeGame.cpp(32) : error C2509: '_GetBaseMessageMap' : member function not declared in 'CSnakeGame'
c:\users\administrator\desktop\snake\snakegame.h(20) : see declaration of 'CSnakeGame'
C:\Users\Administrator\Desktop\Snake\SnakeGame.cpp(32) : error C2509: 'GetMessageMap' : member function not declared in 'CSnakeGame'
c:\users\administrator\desktop\snake\snakegame.h(20) : see declaration of 'CSnakeGame'
C:\Users\Administrator\Desktop\Snake\SnakeGame.cpp(32) : warning C4273: 'protected: static struct AFX_MSGMAP const CWnd::messageMap' : inconsistent dll linkage. dllexport assumed.
C:\Users\Administrator\Desktop\Snake\SnakeGame.cpp(32) : error C2491: 'CSnakeGame::CWnd::messageMap' : definition of dllimport static data member not allowed
C:\Users\Administrator\Desktop\Snake\SnakeGame.cpp(94) : error C2556: 'void __thiscall CSnakeGame::OnPaint(void)' : overloaded function differs only by return type from 'int __thiscall CSnakeGame::OnPaint(void)'
c:\users\administrator\desktop\snake\snakegame.h(41) : see declaration of 'OnPaint'
C:\Users\Administrator\Desktop\Snake\SnakeGame.cpp(94) : error C2371: 'OnPaint' : redefinition; different basic types
c:\users\administrator\desktop\snake\snakegame.h(41) : see declaration of 'OnPaint'
C:\Users\Administrator\Desktop\Snake\SnakeGame.cpp(199) : fatal error C1903: unable to recover from previous error(s); stopping compilation
Generating Code...
Error executing cl.exe. 展开
展开全部
1.检查哪些宏的名字是否正确,是否缺少,rror C2509: '_GetBaseMessageMap' : member function not declared in 'CSnakeGame',类声明中有DECLARE_MESSAGE_MAP()这个吗?后面的就是OnPaint重复定义了。实现文件中有BEGIN_MESSAGE_MAP(XXX, CDialog)和END_MESSAGE_MAP()这个吗?估计是你自己手写代码,一般生产的不会出现这些问题。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询