令牌之前应'{'非限定 ID
expected unqualified id before '{' token
我已经到处搜索,找不到这个经常发生的错误的答案。它真的开始惹恼我了。
无论如何,这是我遇到的错误:
74:1: error: expected unqualified-id before ‘{’ token
81:21: error: ‘chat’ has not been declared
81:5: warning: second argument of ‘int main(int, int**)’ should be ‘char **’ [-Wmain]
118:10: error: ‘clean_up’ was not declared in this scope
我不妨只发布整个程序以避免混淆。我可以注意到我正在遵循教程,但仍然收到这些错误。本教程不提供任何帮助!
#include "SDL/SDL.h"
#include "SDL/SDL_image.h"
#include <string>
const int SCREEN_WIDTH = 640;
const int SCREEN_HEIGHT = 480;
const int SCREEN_BBP = 32;
SDL_Surface* image = NULL;
SDL_Surface* screen = NULL;
SDL_Event event;
SDL_Surface *load_image( std::string filename )
{
SDL_Surface* loadedImage = NULL;
SDL_Surface* optimizedImage = NULL;
loadedImage = IMG_Load( filename.c_str() );
if( loadedImage != NULL )
{
optimizedImage = SDL_DisplayFormat( loadedImage );
SDL_FreeSurface( loadedImage );
}
return optimizedImage;
}
void apply_surface( int x, int y, SDL_Surface* source, SDL_Surface* destination )
{
SDL_Rect offset;
offset.x = x;
offset.y - y;
SDL_BlitSurface( source, NULL, destination, &offset );
}
bool init()
{
if( SDL_Init( SDL_INIT_EVERYTHING ) == -1 )
{
return false;
}
screen = SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BBP, SDL_SWSURFACE );
if( screen == NULL )
{
return false;
}
SDL_WM_SetCaption( "Event test" , NULL );
return true;
}
bool load_files()
{
image = load_image( "x.png" );
if(image == NULL )
{
return false;
}
return true;
}
{
SDL_FreeSurface( image );
SDL_Quit();
}
int main( int argc, chat* args[] )
{
bool quit = false;
if( init() == false )
{
return 1;
}
if( load_files() == false )
{
return 1;
}
apply_surface( 0, 0, image, screen );
if(SDL_Flip( screen ) == -1 )
{
return 1;
}
while( quit == false )
{
while( SDL_PollEvent( &event ) )
{
if( event.type == SDL_QUIT )
{
quit = true;
}
}
}
clean_up();
return 0;
}
有什么帮助吗?
对我来说,您似乎不小心在第 42 行插入了一个分号:
bool init();
{ //this is line 43 in which the compiler is pointing at.
像这样尝试:
bool init()
{ //this is line 43 in which the compiler is pointing at.
bool init(); // <--- you have an extra semicolon here
{ //this is line 43 in which the compiler is pointing at.
删除分号bool init();
相关文章:
- C++:"("令牌"之前有预期的非限定 id 指向类中成员函数的指针
- 错误:令牌 { '{' 之前应存在非限定 ID
- 令牌 C++ 错误之前'['非限定 ID
- 修复令牌错误之前';'预期的非限定 ID
- C 错误:令牌之前'['预期为非限定 id
- "["令牌和 + 之前应为非限定 ID
- 屏幕显示脚本中'.'令牌之前的预期非限定 id
- “OR”令牌之前的预期非限定 ID
- 声明中的限定 ID 在"="令牌/对象计数器变量之前
- 需要调试"在')'令牌之前预期的非限定id",第一次使用c ++的用户
- 在"." 令牌之前应为非限定 ID(C++ 错误)
- 在“.”令牌之前应为非限定 ID
- 令牌之前应'{'非限定 ID
- 函数概率:令牌之前'['预期的非限定 id
- 预期在令牌之前的未合格ID
- 错误:预期的非限定 ID befo 重新'{'令牌
- Arduino 错误在令牌之前预期为非限定 id '/'
- 错误:在 Arduino 中'{'令牌之前预期未限定 ID
- 令牌之前')'预期的非限定 id?
- 令牌之前应为非限定 ID ')'