title: compiler problems with variable template
body: <p>The following code (taken from <a href="https://en.wikipedia.org/wiki/C%2B%2B14" rel="nofollow noreferrer">Wikipedia</a>) defines the <a href="https://en.cppreference.com/w/cpp/language/variable_template" rel="nofollow noreferrer">variable template</a> <code>pi&lt;&gt;</code>:</p>
  <pre><code>template&lt;typename T=double&gt;
  constexpr T pi = T(3.14159265358979323846264338328);
  template&lt;&gt;
  constexpr const char* pi&lt;const char*&gt; = &quot;π&quot;;
  </code></pre>
  <p>With the clang compiler (Apple clang version 12.0.0) (with C++14), this triggers a <strong>warning</strong> (with <code>-Weverything</code>):</p>
  <blockquote>
  <p>no previous extern declaration for non-static variable 'pi&lt;const char *&gt;'</p>
  <p>declare 'static' if the variable is not intended to be used outside of this translation unit</p>
  </blockquote>
  <p>Moreover, since this was defined in a header, multiple instances of 'myNameSpace::pi&lt;char const*&gt;' were created, causing <strong>linker errors</strong>.</p>
  <p>So, as suggested, I added the <code>static</code> keyword, which silenced the warning:</p>
  <pre><code>template&lt;&gt;
  static constexpr const char* pi&lt;const char*&gt; = &quot;π&quot;;
  </code></pre>
  <p>But now gcc (9.3.0) is unhappy, giving an <strong>error</strong> pointing at the <code>static</code> keyword:</p>
  <blockquote>
  <p>error: explicit template specialization cannot have a storage class</p>
  </blockquote>
  <p>What is the correct way to avoid either warning and error?</p>