Sign in to follow this  

SDL error...

This topic is 4687 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, i just set up SDL and SDL_image for DevC++, but even when i try to compile the example it comes with i get this error, In file included from C:/Dev-Cpp/include/SDL/SDL.h:39, C:\Dev-Cpp\include\SDL\SDL_audio.h syntax error before `[' token when i open that file the error is on line "void (SDLCALL *filters[10])(struct SDL_AudioCVT *cvt, Uint16 format);" i didnt edit any of the files or anything, am i missing a Devpack or somthing?, oh and i have both the .dll files in the programs home directory, any ideas? thanks in advanced

Share this post


Link to post
Share on other sites
Quote:
Original post by Drew_Benton
Take out the 'SDLCALL' it is a known error with Dev-CPP. I usually just comment out that entire line to make life easier.

ah ok, thanks :P

Share this post


Link to post
Share on other sites
err ok one more thing :D now while im compiling i get this following,

[Linker error] undefined reference to `IMG_Load'
[Linker error] undefined reference to `SDL_FreeSurface'

why is this? im sorry if this is a really simple question, but im a noob :P

Share this post


Link to post
Share on other sites
Not a problem you need to link in the libraries:

-lmingw32
-lsdlmain
-lsdl


This can be done by going to Project->Project Options->Parameters and add them to the linker box. Have a look at these tutorials as well. They show some good basics to get up and runnig with SDL, including a small game. You can also find game tutorials here.

- Drew

Share this post


Link to post
Share on other sites
IMG_Load is provided by SDL_image, you'll need to link with that as well. So add -lSDL_image to that list.

As for the line with the error, _don't_ remove it, that will change the size of the struct and the offset of some of the members. Remove STDCALL instead.

Share this post


Link to post
Share on other sites
Quote:
Original post by jonahrowley
As for the line with the error, _don't_ remove it, that will change the size of the struct and the offset of some of the members. Remove STDCALL instead.


Ahh yes, you are right. It is a good idea not to remove it, my mistake, especially if you are going to be using audio [lol]. Then your SDL mixer would have died and you would have had no idea. I better take note of that so I can remember next time.

- Drew

Share this post


Link to post
Share on other sites
Quote:
Original post by Drew_Benton
Quote:
Original post by jonahrowley
As for the line with the error, _don't_ remove it, that will change the size of the struct and the offset of some of the members. Remove STDCALL instead.


Ahh yes, you are right. It is a good idea not to remove it, my mistake, especially if you are going to be using audio [lol]. Then your SDL mixer would have died and you would have had no idea. I better take note of that so I can remember next time.

- Drew

oh ok, thank you :D

Edit: ok umm...what line was that on? i just removed it i think, since i cant seem to find it anymore :P

Share this post


Link to post
Share on other sites
Ok open up "SDL_audio.h". From line 86-99 this is what it is supposed to be.


/* A structure to hold a set of audio conversion filters and buffers */
typedef struct SDL_AudioCVT {
int needed; /* Set to 1 if conversion possible */
Uint16 src_format; /* Source audio format */
Uint16 dst_format; /* Target audio format */
double rate_incr; /* Rate conversion increment */
Uint8 *buf; /* Buffer to hold entire audio data */
int len; /* Length of original audio buffer */
int len_cvt; /* Length of converted audio buffer */
int len_mult; /* buffer must be len*len_mult big */
double len_ratio; /* Given len, final size is len*len_ratio */
void (*filters[10])(struct SDL_AudioCVT *cvt, Uint16 format);
int filter_index; /* Current audio conversion function */
} SDL_AudioCVT;


Line 97 used to be this:

void (SDLCALL *filters[10])(struct SDL_AudioCVT *cvt, Uint16 format);


- Drew

Share this post


Link to post
Share on other sites

This topic is 4687 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this