I keep getting an error when compiling an SDL program I'm working on.
I get the "'screen' was not declared in this scope" error, even though I'm pretty sure it's declared in 'globals.h'.
globals.h
#ifndef GLOBALS_H_INCLUDED
#define GLOBALS_H_INCLUDED
#include "gui.h"
#include "player.h"
#include "SDL.h"
#include "timer.h"
#include <stdlib.h>
#include <string>
SDL_Surface* screen = NULL;
SDL_Event event;
bool done;
int screenW = 640, screenH = 480
#endif
setup.h
#ifndef SETUP_H_INCLUDED
#define SETUP_H_INCLUDED
#include "globals.h"
#include "SDL.h"
#include "SDL_ttf.h"
#include <windows.h>
int createWindow()
{
SDL_Init( SDL_INIT_EVERYTHING );
TTF_Init();
if(SDL_Init(SDL_INIT_VIDEO) < 0)
{
printf("Unable to initialize SDL: %s\n", SDL_GetError());
return 1;
}
SDL_WM_SetCaption( "Thing", NULL );
screen = SDL_SetVideoMode(screenW, screenH, 32, SDL_HWSURFACE|SDL_DOUBLEBUF|SDL_HWACCEL/*|SDL_RESIZABLE*/);
if(!screen)
{
printf("Unable to set %ix%i video: %s\n", screenW, screenH, SDL_GetError());
return 1;
}
return 0;
}
#endif
I get the error in the createWindow() function. It also says 'screenW' and 'screenH' aren't declared. Why is this? global.h is included and it worked all the time up until now.