简体   繁体   English

从 SDL 教程构建示例程序时的 GCC 错误

[英]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.我正在尝试从这里的旧 SDL 教程构建此示例程序 dots.c。 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. http://www.dreamincode.net/forums/topic/64143-game-programming-in-linux-for-windows-programmers-part-2/我从 GCC 收到错误,我认为这可能与缺少 C 有关我的复制粘贴或原始 HTML 表示省略了转义序列。 But I don't know enough about C to say one way or the other.但我对 C 的了解不够,无法以一种或另一种方式说。 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 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 64-66

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

89-91 89-91

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

111-113 111-113

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

130-132 130-132

/* Main */
int main()
{

158-163 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.在教程代码中的第 41、51、55、59 行以 /> 的形式存在杂散的 HTML。在 GCC 成功构建之前必须删除这些。 Thanks to tkausl for suggesting the solution.感谢 tkausl 提出解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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