我试图从这里的旧SDL教程构建这个示例程序dots.c。 http://www.dreamincode.net/forums/topic/64143-game-programming-in-linux-for-windows-programmers-part-2/我从GCC收到错误,我认为这可能与丢失的C转义序列有关,我的复制粘贴或原始HTML表示都省略了这些错误。但是,我不太了解C,不管怎么说。我想知道代码需要哪些更改来清除这些构建错误,理想情况是您如何识别这些错误。谢谢。
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;
}
答案 0 :(得分:0)
在第41,51,55,59行的/>'形式的教程代码中有杂散HTML。必须在GCC成功构建之前删除这些HTML。感谢tkausl建议解决方案。