简体   繁体   中英

GCC Errors When Building Example Program From SDL Tutorial

I'm trying to build this example program dots.c from an old SDL tutorial here. http://www.dreamincode.net/forums/topic/64143-game-programming-in-linux-for-windows-programmers-part-2/ I'm getting errors from GCC which I think may be related to missing C escape sequences which were omitted either by my copy-pasting or the original HTML representation. But I don't know enough about C to say one way or the other. I'd like to know what changes the code needs to clear these build errors, ideally with how you identified those. Thank you.

dots.c:41:94: error: expected declaration specifiers before ‘/’ token
 void set_sdl_pixel(SDL_PixelFormat *what,void *pixel,int width,int x,int y,int r,int g,int B)/>
                                                                                              ^
dots.c:66:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
 {
 ^
dots.c:91:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
 {
 ^
dots.c:113:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
 {
 ^
dots.c:132:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
 {
 ^
dots.c:163:1: error: expected ‘{’ at end of input
 }
 ^

40-42

/* Sets a pixel in a surface, paying attention to pixel format */
void set_sdl_pixel(SDL_PixelFormat *what,void *pixel,int width,int x,int y,int r,int g,int B)/>
{

64-66

/* Draws things using direct access to the surface */
void draw_pixels(SDL_Surface *screen)
{

89-91

/* Initializes the game */
void game_init()
{

111-113

/* Processes everything in the game for a frame */
void game_main()
{

130-132

/* Main */
int main()
{

158-163

    }
    /* Exit SDL */
    SDL_Quit();
    /* Exit */
    return 0;
}

There was stray HTML in the tutorial code in the form of />'s on lines 41,51, 55, 59. These had to be deleted before GCC would successfully build. Thanks to tkausl for suggesting the solution.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM