void __init init(SDL_Surface* screen) {
/* Initialze SDL */
SDL_Init(SDL_INIT_EVERYTHING);
scr_t* scr;
/* Set up the screen: */
scr->scr_width = 1024;
scr->scr_height = 768;
scr->scr_bpp = 32;
screen = SDL_SetVideoMode(
scr->scr_width, scr->scr_height, scr->scr_bpp,
SDL_SWSURFACE | SDL_DOUBLEBUF /* We want a double buffered screen */
);
if (screen == NULL) {
die("Error: Couldn't set video mode.\n");
}
}
It is at the point where I use the arrow operator that it segfaults.
Why is this? I always get segfaults using it; so obviously I'm doing something wrong. I googled it and I got this page http://boredzo.org/pointers/#structures and it looks to me like he's accessing a structure in the same way I am :l
Here is the structure:
1 2 3 4 5
typedefstruct scr {
int scr_width; /* Screen height */
int scr_height; /* Screen width */
int scr_bpp; /* Bits per pixel (colour depth) */
} scr_t;
I thought for the moment that, though unlikely, it might be the typedef. I tried it like this: