使用外部变量加extern
When we define a const with the same name in multiple files, it is as if we had written definitions for separate variables in each file.
Sometimes we have a const variable that we want to share across multiple files but whose initializer is not a constant expression. In this case, we don’t want the compiler to generate a separate variable in each file. Instead, we want the const object to behave like other (non const ) variables. We want to define the const in one file, and declare it in the other files that use that object.
// file_1.cc defines and initializes a const that is accessible to other files
extern const int bufSize = fcn(); // file_1.h
extern const int bufSize;// same bufSize as defined in file_1.cc