Unique address for constexpr variable
问题 Is it possible to have a unique address allocated for a constexpr variable, i.e. the same for all translation units where the variable is available (usually through a header)? Consider the following example: // foo.hh #include <iostream> constexpr int foo = 42; // a.cc #include "foo.hh" void a(void) { std::cout << "a: " << &foo << std::endl; } // b.cc #include "foo.hh" extern void a(void); int main(int argc, char** argv) { a(); std::cout << "b: " << &foo << std::endl; } Compiling a.cc and b