Valmond
Valmond

Reputation: 2969

Why does value assignment exclude extern keyword and declare variable?

I understand why this won't link:

extern bool g_WinGame;
...
g_WinGame=true;

But why does this compile and link?

extern bool g_WinGame=false;
...
g_WinGame=true;

I'm using MSVC 2010

[edit] all is explained HERE

Upvotes: 0

Views: 201

Answers (1)

R Sahu
R Sahu

Reputation: 206567

extern bool g_WinGame;

is a declaration.

extern bool g_WinGame=false;

is a definition. Here extern is redundant but legal.

Upvotes: 3

Related Questions