if I define my constant varibles in my header like this...
extern const double PI = 3.1415926535;
extern const double PI_under_180 = 180.0f / PI;
extern cons
An old question, indeed, but one useful answer is missing.
It is possible to trick MSVC into accepting static constants in headers simply by wrapping those in a "dummy" class template:
template
struct C {
static const double Pi;
};
template
const double C::Pi = 3.14159;
Now, C<>::PI can be accessed from elsewhere. No redefinition complains; constant is directly accessible in each compilation units without fancy link time optimization. Macro can be rolled out to further prettify this approach (even though macros are evil).