I am trying to create a namespace-scope constant with external linkage
// in some include file:
namespace foo
{
constexpr double bar() { return 1.23456; } // internal linkage
constexpr double baz = 1.23456; // internal linkage
const double bing = 1.23456; // internal linkage
}
Is this even possible?
Yes, and no; you can use
extern:So:
In your other translation unit, you should now be able to declare the function’s name and refer to it:
However, the rules for
constexprvariables state that you cannot have a declaration that is not also a definition:So, you cannot take the same approach with
baz.