Reputation: 4197
I have some extern
'd variables in a namespace in a header file, and I'm trying to initialize them in its corresponding cpp file. However, I keep getting the error given in the topic title. I'm not sure what the problem is.
EX:
// Some header
namespace foo
{
extern SDL_Surface* bar;
}
// In the impl file
#include "someheader.h"
foo::bar = 0;
.....
Any assistance is appreciated. Thanks.
Upvotes: 0
Views: 1614
Reputation: 18984
It doesn't know what type SDL_Surface is. You need to define it or at least forward declare it.
Upvotes: 0
Reputation: 76531
At the file level, you can only define types (you've only written an assignment expression). So you need to change that to:
SDL_Surface* foo::bar = 0;
Upvotes: 4