[cfe-dev] Clang and C++Ox : what I'm doing wrong
Argyrios Kyrtzidis
kyrtzidis at apple.com
Fri Oct 8 09:00:17 PDT 2010
On Oct 8, 2010, at 8:49 AM, John McCall wrote:
>
> On Oct 8, 2010, at 8:47 AM, Argyrios Kyrtzidis wrote:
>
>> On Oct 8, 2010, at 12:27 AM, Jaonary Rabarisoa wrote:
>>
>>> 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
>>
>> Why are we requiring a definition for Test::value, isn't this supposed to be used as a constant ? John ?
>
> Probably various places don't realize that they can emit that as a constant.
Jaonary, please file a bug report so we can keep track of this.
-Argiris
>
> John.
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
More information about the cfe-dev
mailing list