title: How can I initialize class variables in a header?
body: <p>I'm writing a library where the user can define arbitrary structures and pass them to my library, which will then obtain the memory layout of the structure from a static member such structure must have as a convention.</p>
  
  <p>For example:</p>
  
  <pre><code>struct CubeVertex {
    // This is, per convention, required in each structure to describe itself
    static const VertexElement Elements[];
  
    float x, y, z;
    float u, v;
  };
  
  const VertexElement CubeVertex::Elements[] = {
    VertexElement("Position", VertexElementType::Float3),
    VertexElement("TextureCoordinates", VertexElementType::Float2),
  };
  </code></pre>
  
  <p>C++ best practices would suggest that I move the static variable and its initialization into my source (.cpp) file. I, however, want to keep the variable initialization as close to the structure as possible since whenever the structure changes, the variable has to be updated as well.</p>
  
  <p>Is there a portable (<em>= MSVC + GCC at least</em>) way to declare such a variable inside the header file without causing ambiguous symbol / redefinition errors from the linker?</p>