Thread: SDL error

  1. #1
    Registered User
    Join Date
    Jan 2005
    Posts
    106

    SDL error

    Every time I try to compile a file that uses SDL, I get the following error:

    In file included from C:\DEV-C_~1\Include\sdl.h:39,
    from c:\documents and settings\owner\my documents\c++\keypresstest.cpp:1:
    C:\DEV-C_~1\Include\SDL_audio.h:97: parse error before `['

    Any idea what's up?

    I'm using Dev-c++ v4, btw.

  2. #2
    Slave MadCow257's Avatar
    Join Date
    Jan 2005
    Posts
    735
    Post some related code please, I can't deduce the problem from that very limited amount of information.

  3. #3
    Registered User
    Join Date
    Jan 2005
    Posts
    106
    Code:
    #include <SDL.h>
    
    int main(int argc, char *argv[])
    {
    
    return 0;
    }

  4. #4
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    This is a known parsing error with certain versions of gcc I believe. I googled for it, and i encourage you to do the same, and came up with two fixes:

    1) Downgrade to SDL 1.2.7, it compiles fine.
    2) Or keep 1.2.8 and edit the SDL_audio.h, line 97 to make it work with g++
    You only need to change:
    void (SDLCALL *filters [10])(struct SDL_AudioCVT *cvt, Uint16 format);
    to:
    void (*filters [10])(struct SDL_AudioCVT *cvt, Uint16 format);
    "...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers

  5. #5
    Registered User
    Join Date
    Jan 2005
    Posts
    106
    Er, I mean, getting different errors.

    C:\DEV-C_~1\Lib\\libsdl.a(SDL_systimer.o): In function `SDL_StartTicks':
    /home/hercules/release/SDL-1.2.8/src/timer/SDL_systimer.c:73: undefined reference to `timeBeginPeriod@4'
    /home/hercules/release/SDL-1.2.8/src/timer/SDL_systimer.c:74: undefined reference to `timeGetTime@0'
    C:\DEV-C_~1\Lib\\libsdl.a(SDL_systimer.o): In function `SDL_GetTicks':
    /home/hercules/release/SDL-1.2.8/src/timer/SDL_systimer.c:101: undefined reference to `timeGetTime@0'
    C:\DEV-C_~1\Lib\\libsdl.a(SDL_systimer.o): In function `SDL_SYS_TimerInit':
    /home/hercules/release/SDL-1.2.8/src/timer/SDL_systimer.c:189: undefined reference to `timeBeginPeriod@4'
    /home/hercules/release/SDL-1.2.8/src/timer/SDL_systimer.c:195: undefined reference to `timeSetEvent@20'
    C:\DEV-C_~1\Lib\\libsdl.a(SDL_systimer.o): In function `SDL_SYS_TimerQuit':
    /home/hercules/release/SDL-1.2.8/src/timer/SDL_systimer.c:208: undefined reference to `timeEndPeriod@4'
    /home/hercules/release/SDL-1.2.8/src/timer/SDL_systimer.c:206: undefined reference to `timeKillEvent@4'
    /home/hercules/release/SDL-1.2.8/src/timer/SDL_systimer.c:208: undefined reference to `timeEndPeriod@4'

    Here's the first fifth or so of the error log. I tried googling stuff on that. The only page I could get was in french.
    Last edited by suzakugaiden; 03-18-2005 at 08:57 PM.

  6. #6
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    Link to winmm.lib
    "...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Testing some code, lots of errors...
    By Sparrowhawk in forum C Programming
    Replies: 48
    Last Post: 12-15-2008, 04:09 AM
  2. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  3. Crazy errors caused by class, never seen before..
    By Shamino in forum C++ Programming
    Replies: 2
    Last Post: 06-10-2007, 11:54 AM
  4. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 08:39 AM
  5. Stupid compiler errors
    By ChrisEacrett in forum C++ Programming
    Replies: 9
    Last Post: 11-30-2003, 05:44 PM