Unresolved External Symbol???????
Jan 18, 2011 at 3:41am UTC
So I am using SDL and I created a .cpp file with declaritons of global varibles then a header with extern declartions. I then included the header into a intiation file and it comes back the const ints were unresolved external symbols
Here is the .cpp with the declartions
1 2 3 4 5 6 7 8
using namespace std;
#include <SDL.h>
//screen attributes
SDL_Surface *screen = NULL;
const int SCREEN_WIDTH = 800;
const int SCREEN_HEIGHT = 600;
const int SCREEN_BPP = 32;
//global variables
Here is the Header
1 2 3 4 5 6
using namespace std;
#include <SDL.h>
extern SDL_Surface *screen;
extern const int SCREEN_WIDTH;
extern const int SCREEN_HEIGHT;
extern const int SCREEN_BPP;
And the intiaion file
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
#include <SDL.h>
#include <SDL_main.h>
#include "Screen_Global.h"
#include "Render.h"
using namespace std;
bool init()
{
//Initialize all SDL subsystems
if ( SDL_Init( SDL_INIT_EVERYTHING ) == -1 )
{
return false ;
}
//Set up the screen
screen = SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_SWSURFACE );
//If there was an error in setting up the screen
if ( screen == NULL )
{
return false ;
}
//Set the window caption
SDL_WM_SetCaption( "Event test" , NULL );
//If everything initialized fine
return true ;
}
Any help would be greatly appreciated.
Jan 18, 2011 at 10:50am UTC
const ...
is resolved directly without having variables. just put them in your header.
Topic archived. No new replies allowed.