title: Static constant class member declaration
body: <p>in Foo.h:</p>
  
  <pre><code>class Foo
  {
  public:
      Foo();
      static const unsigned int FOOBAR = 10;
      static const unsigned int BARFOO = 20;
  
  private:
      unsigned int m_FooBar;
      bool m_Bar;
      void Bar();
  };
  </code></pre>
  
  <p>in Foo.cpp:</p>
  
  <pre><code>Foo::Foo()
      : m_FooBar(FOOBAR), // this works
        m_Bar(false)
  {
  }
  
  void Foo::Bar()
  {
      //m_FooBar = m_Bar ? FOOBAR : BARFOO; // linker fails *1
      m_FooBar = FOOBAR; // ok
  }
  </code></pre>
  
  <p>I'm compiling with GCC 4.5.3. Is there any reason why the linker would fail when line *1 is uncommented?</p>
  
  <pre><code>Foo.o: In function 'Foo::Bar' (name unmangled):
  Foo.cpp: undefined reference to `Foo::FOOBAR'
  Foo.cpp: undefined reference to `Foo::BARFOO'
  </code></pre>
  
  <p>Tried with VC2005, 2008, 2010 and CB2010. They all compiled and linked fine. Why does GCC fail in this case?</p>
  
  <p>Given the <a href="https://stackoverflow.com/questions/5446005/why-dont-static-member-variables-play-well-with-the-ternary-operator">answer here</a>, why doesn't the other popular compilers fail like GCC? One way or another, it has to be a bug, either for GCC or the other popular compilers. Or is there a more reasonable explanation?</p>