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
extern bool g_WinGame;
is a declaration.
extern bool g_WinGame=false;
is a definition. Here extern
is redundant but legal.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.