2014-02-17 3 views
-5

Я искал повсюду и не могу найти ответ на эту довольно часто повторяющуюся ошибку. Его действительно начинает раздражать меня.ожидаемый неквалифицированный идентификатор до '{' 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; 
} 

Любая помощь?

ответ

1

Для Mee похоже, что вы случайно вставили точку с запятой в строке 42:

bool init(); 
{ //this is line 43 in which the compiler is pointing at. 

Try это так:

bool init() 
{ //this is line 43 in which the compiler is pointing at. 
+0

я пытался что и он придумал кучу других подобных ошибок. –

+1

Не могли бы вы показать нам ошибки? Возможно, у вас есть простые ошибки в другом месте кода – Mikescher

1
bool init(); // <--- you have an extra semicolon here 
{ //this is line 43 in which the compiler is pointing at. 
1

Удалите точку с запятой bool init();

Смежные вопросы