I have the following 5 files: global_vars.h, global_vars.cpp content.h content.cpp main.cpp.
global_vars.h
#ifndef global_vars_h #define global_vars_h namespace Constants{ extern const unsigned int b; } #endif global_vars.cpp
#include "global_vars.h" namespace Constants{ extern const unsigned int b(5); } content.h
#ifndef CONTENT_H_ #define CONTENT_H_ #include "global_vars.h" #include <bitset> struct a{ std::bitset<Constants::b> s; int a=10; }; #endif content.cpp
#include "content.h" a xVar; main.cpp
#include "content.h" int main(){ return 0; } I get the following errors:
In file included from content.cpp:1:0: content.h:11:31: error: the value of ‘Constants::b’ is not usable in a constant expression In file included from content.h:4:0, from content.cpp:1: global_vars.h:6:28: note: ‘Constants::b’ was not initialized with a constant expression extern const unsigned int b; I have to use Constants::b in files other than content.cpp/.h (for other bitsets) as well so how can I go around doing this? Appreciate the help.
thanks