[cfe-dev] Compile error using Clang

Wei Li weili747 at gmail.com
Fri Aug 27 12:17:14 PDT 2010


On Fri, Aug 27, 2010 at 11:07 AM, Douglas Gregor <dgregor at apple.com> wrote:
>
> On Aug 27, 2010, at 9:00 AM, Wei Li wrote:
>
>> Dear All:
>>
>> I am getting the following error for the following simple test.cpp code:
>>
>>
>> #include <iostream>
>>
>> using namespace std;
>>
>> int main(void){
>>
>>
>>
>>        return 1;
>>
>> }
>
> Clang doesn't support the standard library (libstdc++) that comes with GCC < 4.2. We'll accept patches to make it work, but right now it doesn't work out-of-the-box. Do you have headers for a newer libstdc++ available?
>
>        - Doug
>

Thanks Will it work if I install a newer version of GCC? What
part of the Makefile I have to change so that it can detect the new
version of GCC installed separately. I went through the Makefile and
could not figure it out. or is there any flag which I can use when I
run ./configure command?


Thanks

--



>> ----------------------------------------------------------------
>> ./install/bin/clang++ ./test.cpp
>> In file included from ./test.cpp:1:
>> In file included from /usr/include/c++/4.1.2/iostream:43:
>> In file included from /usr/include/c++/4.1.2/ostream:43:
>> In file included from /usr/include/c++/4.1.2/ios:42:
>> In file included from /usr/include/c++/4.1.2/iosfwd:45:
>> In file included from
>> /usr/include/c++/4.1.2/x86_64-redhat-linux/bits/c++io.h:38:
>> In file included from
>> /usr/include/c++/4.1.2/x86_64-redhat-linux/bits/gthr.h:132:
>> /usr/include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:100:1:
>> error: weakref declaration of '__gthrw_pthread_once' must be static
>> __gthrw(pthread_once)
>> ^
>> /usr/include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:81:23:
>> note: instantiated from:
>> #define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name)
>>                      ^
>> /usr/include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:72:46:
>> note: instantiated from:
>>  extern __typeof(type) name __attribute__ ((__weakref__(#name2))); \
>>                                             ^
>> /usr/include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:101:1:
>> error: weakref declaration of '__gthrw_pthread_getspecific' must be
>> static
>> __gthrw(pthread_getspecific)
>> ^
>> /usr/include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:81:23:
>> note: instantiated from:
>> #define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name)
>>                      ^
>> /usr/include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:72:46:
>> note: instantiated from:
>>  extern __typeof(type) name __attribute__ ((__weakref__(#name2))); \
>>                                             ^
>> /usr/include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:102:1:
>> error: weakref declaration of '__gthrw_pthread_setspecific' must be
>> static
>> __gthrw(pthread_setspecific)
>> ^
>> /usr/include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:81:23:
>> note: instantiated from:
>> #define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name)
>>                      ^
>> /usr/include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:72:46:
>> note: instantiated from:
>>  extern __typeof(type) name __attribute__ ((__weakref__(#name2))); \
>>                                             ^
>> /usr/include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:103:1:
>> error: weakref declaration of '__gthrw_pthread_create' must be static
>> __gthrw(pthread_create)
>> ^
>> /usr/include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:81:23:
>> note: instantiated from:
>> #define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name)
>>                      ^
>> /usr/include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:72:46:
>> note: instantiated from:
>>  extern __typeof(type) name __attribute__ ((__weakref__(#name2))); \
>>                                             ^
>> /usr/include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:104:1:
>> error: weakref declaration of '__gthrw_pthread_cancel' must be static
>> __gthrw(pthread_cancel)
>> ^
>> /usr/include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:81:23:
>> note: instantiated from:
>> #define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name)
>>                      ^
>> /usr/include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:72:46:
>> note: instantiated from:
>>  extern __typeof(type) name __attribute__ ((__weakref__(#name2))); \
>>                                             ^
>> /usr/include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:105:1:
>> error: weakref declaration of '__gthrw_pthread_mutex_lock' must be
>> static
>> __gthrw(pthread_mutex_lock)
>> ^
>> /usr/include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:81:23:
>> note: instantiated from:
>> #define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name)
>>                      ^
>> /usr/include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:72:46:
>> note: instantiated from:
>>  extern __typeof(type) name __attribute__ ((__weakref__(#name2))); \
>>                                             ^
>> /usr/include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:106:1:
>> error: weakref declaration of '__gthrw_pthread_mutex_trylock' must be
>> static
>> __gthrw(pthread_mutex_trylock)
>> ^
>> /usr/include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:81:23:
>> note: instantiated from:
>> #define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name)
>>                      ^
>> /usr/include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:72:46:
>> note: instantiated from:
>>  extern __typeof(type) name __attribute__ ((__weakref__(#name2))); \
>>                                             ^
>> /usr/include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:107:1:
>> error: weakref declaration of '__gthrw_pthread_mutex_unlock' must be
>> static
>> __gthrw(pthread_mutex_unlock)
>> ^
>> /usr/include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:81:23:
>> note: instantiated from:
>> #define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name)
>>                      ^
>> /usr/include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:72:46:
>> note: instantiated from:
>>  extern __typeof(type) name __attribute__ ((__weakref__(#name2))); \
>>                                             ^
>> /usr/include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:108:1:
>> error: weakref declaration of '__gthrw_pthread_mutex_init' must be
>> static
>> __gthrw(pthread_mutex_init)
>> ^
>> /usr/include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:81:23:
>> note: instantiated from:
>> #define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name)
>>                      ^
>> /usr/include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:72:46:
>> note: instantiated from:
>>  extern __typeof(type) name __attribute__ ((__weakref__(#name2))); \
>>                                             ^
>> /usr/include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:109:1:
>> error: weakref declaration of '__gthrw_pthread_cond_broadcast' must be
>> static
>> __gthrw(pthread_cond_broadcast)
>> ^
>> /usr/include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:81:23:
>> note: instantiated from:
>> #define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name)
>>                      ^
>> /usr/include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:72:46:
>> note: instantiated from:
>>  extern __typeof(type) name __attribute__ ((__weakref__(#name2))); \
>>                                             ^
>> /usr/include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:110:1:
>> error: weakref declaration of '__gthrw_pthread_cond_wait' must be
>> static
>> __gthrw(pthread_cond_wait)
>> ^
>> /usr/include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:81:23:
>> note: instantiated from:
>> #define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name)
>>                      ^
>> /usr/include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:72:46:
>> note: instantiated from:
>>  extern __typeof(type) name __attribute__ ((__weakref__(#name2))); \
>>                                             ^
>> /usr/include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:113:1:
>> error: weakref declaration of '__gthrw_pthread_key_create' must be
>> static
>> __gthrw(pthread_key_create)
>> ^
>> /usr/include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:81:23:
>> note: instantiated from:
>> #define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name)
>>                      ^
>> /usr/include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:72:46:
>> note: instantiated from:
>>  extern __typeof(type) name __attribute__ ((__weakref__(#name2))); \
>>                                             ^
>> /usr/include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:114:1:
>> error: weakref declaration of '__gthrw_pthread_key_delete' must be
>> static
>> __gthrw(pthread_key_delete)
>> ^
>> /usr/include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:81:23:
>> note: instantiated from:
>> #define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name)
>>                      ^
>> /usr/include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:72:46:
>> note: instantiated from:
>>  extern __typeof(type) name __attribute__ ((__weakref__(#name2))); \
>>                                             ^
>> /usr/include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:115:1:
>> error: weakref declaration of '__gthrw_pthread_mutexattr_init' must be
>> static
>> __gthrw(pthread_mutexattr_init)
>> ^
>> /usr/include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:81:23:
>> note: instantiated from:
>> #define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name)
>>                      ^
>> /usr/include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:72:46:
>> note: instantiated from:
>>  extern __typeof(type) name __attribute__ ((__weakref__(#name2))); \
>>                                             ^
>> /usr/include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:116:1:
>> error: weakref declaration of '__gthrw_pthread_mutexattr_settype' must
>> be static
>> __gthrw(pthread_mutexattr_settype)
>> ^
>> /usr/include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:81:23:
>> note: instantiated from:
>> #define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name)
>>                      ^
>> /usr/include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:72:46:
>> note: instantiated from:
>>  extern __typeof(type) name __attribute__ ((__weakref__(#name2))); \
>>                                             ^
>> /usr/include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:117:1:
>> error: weakref declaration of '__gthrw_pthread_mutexattr_destroy' must
>> be static
>> __gthrw(pthread_mutexattr_destroy)
>> ^
>> /usr/include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:81:23:
>> note: instantiated from:
>> #define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name)
>>                      ^
>> /usr/include/c++/4.1.2/x86_64-redhat-linux/bits/gthr-default.h:72:46:
>> note: instantiated from:
>>  extern __typeof(type) name __attribute__ ((__weakref__(#name2))); \
>>                                             ^
>> 16 errors generated.
>>
>>
>>
>>
>> --
>> Regards,
>>
>> Wei Li
>> _______________________________________________
>> cfe-dev mailing list
>> cfe-dev at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
>



Regards,

Wei Li



-- 
Regards,

Wei Li




More information about the cfe-dev mailing list