   Can't have extern static bool?
  Ok, so I'm working in C++ and I have one source file and a header file.  There is a boolean variable named localMode that is defined in the source file but access elsewhere in the project.  Here's the relevant code:Utils.h#ifndef UTILS_H#define UTILS_Hnamespace utils{    extern bool localMode;}#endifUtils.cpp#include "Utils.h"namespace utils{    static bool localMode = false;}I use this variable in a one difference source file (named Upload.cpp), compile them into a static library, and then link to that static library in a different, new test project.  However, I get the following errors when I compile:Quote:Error1error LNK2001: unresolved external symbol "bool utils::localMode" (?localMode@utils@@3_NA)main.objError2error LNK2001: unresolved external symbol "bool utils::localMode" (?localMode@utils@@3_NA)MyLibrary.libThe first one is me trying to use the variable in my test program, and the second error is when the variable is being used in the static library.  Am I doing something wrong?  Obviously I am, but I can't see what!  I am using other variables in a similar way in the same namespace; the only difference with the other variables is that they are const std::strings, but they work just fine!  How come this doesn't work with bools?   
  Global variables declared static in a cpp file can only be accessed in that same cpp file.  Trying to get at them via an extern in another translation unit is not allowed.  That applies regardless of type (bool, int, string, etc).  The same rule also applies to global static functions declared in a cpp file.If you really want access to "localMode" from elsewhere declare a setter and getter method in Utils.h and define them in Utils.cpp where you have access to "localMode".;  When applied to global variables, the static modifier behaves as it does in C, in that its scope is limited to the file in which it's declared. That's why it doesn't appear to exist in your other files. Simply declaring it as 'bool localMode = false;' in Utils.cpp should work fine.   ;  Hmmmm... I swear I get a little more retarded each day.  I totally knew better than to do that.  In fact I had the const std::strings as non-static until I added the static bool yesterday and decided to make them static too.  Thanks to the both of ya!   