[cfe-dev] Clang and C++Ox : what I'm doing wrong

Jaonary Rabarisoa jaonary at gmail.com
Fri Oct 8 00:27:56 PDT 2010


Hi all,

I trying build the following simple code that use a static const variable
inside a class but I got an undefinend reference error :

#include <iostream>

using namespace std;

class Test
{
  public :
    static const double value = 10.0;
};


int main()
{
  cout << "hello "  << Test::value << endl;
  return 0;
}

This code produce the following warning and error at link time :

clang: warning: argument unused during compilation: '-cc1'
/home/jrabarisoa/Sandbox/test_clang/main.cpp:27:25: warning: in-class
initializer for static data member of type 'const double' is a
      C++0x extension [-Wc++0x-extensions]
    static const double value = 10.0;
                        ^       ~~~~
1 warning generated.
Linking CXX executable test
g++: unrecognized option '-cc1'
CMakeFiles/test.dir/main.cpp.o: In function `main':
/home/jrabarisoa/Sandbox/test_clang/main.cpp:(.text+0x7a): undefined
reference to `Test::value'
collect2: ld returned 1 exit status

What I've missed ?

I use the latest clang from the svn repository.

Regards,

Jaonary
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20101008/221f47dd/attachment.html>


More information about the cfe-dev mailing list