M
Mark
I keep getting this multiple definition of scr error. It says it's
defined once in main.cc, and first defined in screen.cc
I'm assuming this is because both screen.cc and main.cc include
screen.h, but I figured the #ifndef would take care of that. If
that's not what it's good for, what IS it good for? Anyways, I'm
clearly doing something wrong, what is the proper way of setting this
up?
// main.cc
#include "screen.h"
int main(int argc, char *argv[])
{
SDL_Quit();
return EXIT_SUCCESS;
}
// screen.cc
#include <SDL_image.h>
#include "screen.h"
extern SDL_Surface *scr;
void screen(int width, int height, const char *title, const char
*icon)
{
SDL_Init(SDL_INIT_VIDEO);
atexit(SDL_Quit);
SDL_WM_SetCaption(title, 0);
SDL_WM_SetIcon(IMG_Load(icon), 0);
scr = SDL_SetVideoMode ( width, height, 32, SDL_HWSURFACE |
SDL_DOUBLEBUF );
}
// screen.h
#ifndef _screen_H
#define _screen_H
#include "SDL.h"
SDL_Surface *scr;
void screen(int width, int height, const char *title="untitled", const
char *icon=NULL);
#endif /* _screen_H */
defined once in main.cc, and first defined in screen.cc
I'm assuming this is because both screen.cc and main.cc include
screen.h, but I figured the #ifndef would take care of that. If
that's not what it's good for, what IS it good for? Anyways, I'm
clearly doing something wrong, what is the proper way of setting this
up?
// main.cc
#include "screen.h"
int main(int argc, char *argv[])
{
SDL_Quit();
return EXIT_SUCCESS;
}
// screen.cc
#include <SDL_image.h>
#include "screen.h"
extern SDL_Surface *scr;
void screen(int width, int height, const char *title, const char
*icon)
{
SDL_Init(SDL_INIT_VIDEO);
atexit(SDL_Quit);
SDL_WM_SetCaption(title, 0);
SDL_WM_SetIcon(IMG_Load(icon), 0);
scr = SDL_SetVideoMode ( width, height, 32, SDL_HWSURFACE |
SDL_DOUBLEBUF );
}
// screen.h
#ifndef _screen_H
#define _screen_H
#include "SDL.h"
SDL_Surface *scr;
void screen(int width, int height, const char *title="untitled", const
char *icon=NULL);
#endif /* _screen_H */