New C++0x feature support in Clang

Clang has recently gotten much-improved support for the upcoming C++0x standard. In particular, top-of-tree Clang now supports a number of C++0x features:

  - Rvalue references (including rvalue references for *this)
  - Variadic templates
  - Inline namespaces
  - Late-specified return types
  - Decltype

You can turn on C++0x support with the -std=gnu++0x (or, if you want to be more pedantic, -std=c++0x).

Give it a spin, write some tests, try it out with libc++, and tell us how it went! And if you get the itch to hack on Clang, there are a ton of other little C++0x features that you could implement.

  Cheers,
  Doug

A quick reminder about "How to use libc++ with clang" will be welcome at this point :wink:

-- Jean-Daniel

It depends on the platform. On OS X 10.6, download this library:

http://home.roadrunner.com/~hinnant/libcppabi.zip

and copy it into /usr/lib .

This is a low-level library that takes care of things like typeinfo and exception propagation. Once that is taken care of:

$ clang++ -stdlib=libc++ test.cpp

This will assume that /usr/lib/libc++.dylib exists. And the libc++ headers should be installed at /usr/include/c++/v1/ .

If you need to build libc++.dylib, cd into libcxx/lib and execute ./buildit .

I have no experience on running libc++ on other platforms.

-Howard

Thank you, this is exactly what I was looking for.

-- Jean-Daniel

Hi;

Clang has recently gotten much-improved support for the upcoming C++0x standard. In particular, top-of-tree Clang now supports a number of C++0x features:

  • Rvalue references (including rvalue references for *this)
  • Variadic templates
  • Inline namespaces
  • Late-specified return types
  • Decltype

You can turn on C++0x support with the -std=gnu++0x (or, if you want to be more pedantic, -std=c++0x).

Give it a spin, write some tests, try it out with libc++, and tell us how it went! And if you get the itch to hack on Clang, there are a ton of other little C++0x features that you could implement.

A quick reminder about “How to use libc++ with clang” will be welcome at this point :wink:

It depends on the platform. On OS X 10.6, download this library:

http://home.roadrunner.com/~hinnant/libcppabi.zip

and copy it into /usr/lib .

This is a low-level library that takes care of things like typeinfo and exception propagation. Once that is taken care of:

$ clang++ -stdlib=libc++ test.cpp

This will assume that /usr/lib/libc++.dylib exists. And the libc++ headers should be installed at /usr/include/c++/v1/ .

I tried to build on OSX 10.6 and looks like there is a problem with c++ includes:

  • for FILE in ‘…/src/*.cpp’
  • clang++ -c -g -Os -fPIC -nostdinc++ -I…/include …/src/condition_variable.cpp
    …/src/condition_variable.cpp:15:1: warning: inline namespaces are a C++0x feature [-Wc++0x-extensions]
    _LIBCPP_BEGIN_NAMESPACE_STD
    ^
    In file included from …/src/condition_variable.cpp:10:
    In file included from …/include/condition_variable:110:
    …/include/__config:151:52: note: instantiated from:
    #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std {inline namespace _LIBCPP_NAMESPACE {
    ^
    1 warning generated.
  • for FILE in ‘…/src/*.cpp’
  • clang++ -c -g -Os -fPIC -nostdinc++ -I…/include …/src/exception.cpp
    …/src/exception.cpp:14:12: fatal error: ‘cxxabi.h’ file not found
    #include <cxxabi.h>
    ^
    1 error generated.

Regards,
ismail

Sorry, I forgot a step:

$ export TRIPLE=-apple-

before you ./buildit.

-Howard

Hi;

Hi;

Clang has recently gotten much-improved support for the upcoming C++0x standard. In particular, top-of-tree Clang now supports a number of C++0x features:

  • Rvalue references (including rvalue references for *this)
  • Variadic templates
  • Inline namespaces
  • Late-specified return types
  • Decltype

You can turn on C++0x support with the -std=gnu++0x (or, if you want to be more pedantic, -std=c++0x).

Give it a spin, write some tests, try it out with libc++, and tell us how it went! And if you get the itch to hack on Clang, there are a ton of other little C++0x features that you could implement.

A quick reminder about “How to use libc++ with clang” will be welcome at this point :wink:

It depends on the platform. On OS X 10.6, download this library:

http://home.roadrunner.com/~hinnant/libcppabi.zip

and copy it into /usr/lib .

This is a low-level library that takes care of things like typeinfo and exception propagation. Once that is taken care of:

$ clang++ -stdlib=libc++ test.cpp

This will assume that /usr/lib/libc++.dylib exists. And the libc++ headers should be installed at /usr/include/c++/v1/ .

I tried to build on OSX 10.6 and looks like there is a problem with c++ includes:

  • for FILE in ‘…/src/*.cpp’
  • clang++ -c -g -Os -fPIC -nostdinc++ -I…/include …/src/condition_variable.cpp
    …/src/condition_variable.cpp:15:1: warning: inline namespaces are a C++0x feature [-Wc++0x-extensions]
    _LIBCPP_BEGIN_NAMESPACE_STD
    ^
    In file included from …/src/condition_variable.cpp:10:
    In file included from …/include/condition_variable:110:
    …/include/__config:151:52: note: instantiated from:
    #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std {inline namespace _LIBCPP_NAMESPACE {
    ^
    1 warning generated.
  • for FILE in ‘…/src/*.cpp’
  • clang++ -c -g -Os -fPIC -nostdinc++ -I…/include …/src/exception.cpp
    …/src/exception.cpp:14:12: fatal error: ‘cxxabi.h’ file not found
    #include <cxxabi.h>
    ^
    1 error generated.

Regards,
ismail

Sorry, I forgot a step:

$ export TRIPLE=-apple-

before you ./buildit.

Tried;

TRIPLE=x86_64-apple-darwin10 ./buildit

and

TRIPLE=i386-apple-darwin10 ./buildit

but it still can’t find cxxabi.h.

Regards,
ismail

Sorry, I promise this will get better. Place this:

http://home.roadrunner.com/~hinnant/cxxabi.h

in /usr/include

-Howard

Hi;

http://home.roadrunner.com/~hinnant/cxxabi.h

Thanks, nearly done :slight_smile:

  • cc algorithm.o bind.o chrono.o condition_variable.o exception.o future.o hash.o ios.o iostream.o locale.o memory.o mutex.o new.o random.o regex.o stdexcept.o string.o strstream.o system_error.o thread.o typeinfo.o utility.o valarray.o -arch i386 -arch x86_64 -o libc++.1.dylib -dynamiclib -nodefaultlibs -current_version 1 -compatibility_version 1 -install_name /usr/lib/libc++.dylib -Wl,-reexport_library,/usr/lib/libc++abi.dylib -Wl,-unexported_symbols_list,libc++unexp.exp /usr/lib/libSystem.B.dylib
    ld: file not found: /usr/lib/libc++abi.dylib
    collect2: ld returned 1 exit status
    ld: file not found: /usr/lib/libc++abi.dylib
    collect2: ld returned 1 exit status
    lipo: can’t open input file: /var/tmp//ccvV6jJT.out (No such file or directory)

Regards,
ismail

You can find libc++abi.dylib at:

http://home.roadrunner.com/~hinnant/libcppabi.zip

-Howard

This one is easy, and was explain in the first message. You must copy libc++abi.dylib in /usr/lib

http://home.roadrunner.com/~hinnant/libcppabi.zip

– Jean-Daniel

Hi;

Cool, can someone add this to the libc++ web page? :slight_smile:

-Chris

On my to-do, which is rather lengthy today...

-Howard

Clang has recently gotten much-improved support for the upcoming
C++0x standard. In particular, top-of-tree Clang now supports a
number of C++0x features:

  - Rvalue references (including rvalue references for *this)
  - Variadic templates
  - Inline namespaces
  - Late-specified return types
  - Decltype

You can turn on C++0x support with the -std=gnu++0x (or, if you want
to be more pedantic, -std=c++0x).

Give it a spin, write some tests, try it out with libc++, and tell
us how it went!

Thanks Doug.

It worked fine with:

template<typename... T>
struct A
{
    static unsigned const size=sizeof...(T);
};

int main(void)
{
    return A<int,int,int>::size;
}

So I tried the TestVariantBinary.cpp code found in:

  variant_compare.zip

found here:

http://www.boostpro.com/vault/index.php?&direction=0&order=&directory=Data%20Structures

however, that produced compile-time errors as shown below.
What should I do to workaround those errors?

TIA.

-regards,
Larry

/home/evansl/download/llvm/svn/build/Debug+Asserts/bin/clang -c
-std=c++0x
-I/home/evansl/prog_dev/boost-svn/ro/sandbox/rw/variadic_templates/libs/composite_storage/sandbox/pack/variant_compare/ppboost
-I/home/evansl/prog_dev/boost-svn/ro/sandbox/ro/switch
-I/home/evansl/prog_dev/boost-svn/ro/trunk -DTEMPLATE_DEPTH=300
TestVariantBinary.cpp -MMD -o
/home/evansl/prog_dev/boost-svn/ro/trunk/sandbox-local/build/clang/boost-svn/ro/sandbox/rw/variadic_templates/libs/composite_storage/sandbox/pack/variant_compare/TestVariantBinary.o

In file included from TestVariantBinary.cpp:33:
In file included from
/home/evansl/prog_dev/boost-svn/ro/trunk/boost/mpl/vector.hpp:19:
In file included from
/home/evansl/prog_dev/boost-svn/ro/trunk/boost/mpl/aux_/na.hpp:17:
In file included from
/home/evansl/prog_dev/boost-svn/ro/trunk/boost/mpl/bool.hpp:17:
In file included from
/home/evansl/prog_dev/boost-svn/ro/trunk/boost/mpl/bool_fwd.hpp:17:
In file included from
/home/evansl/prog_dev/boost-svn/ro/trunk/boost/mpl/aux_/adl_barrier.hpp:17:
In file included from
/home/evansl/prog_dev/boost-svn/ro/trunk/boost/mpl/aux_/config/adl.hpp:17:
In file included from
/home/evansl/prog_dev/boost-svn/ro/trunk/boost/mpl/aux_/config/msvc.hpp:19:
In file included from
/home/evansl/prog_dev/boost-svn/ro/trunk/boost/config.hpp:40:
In file included from
/home/evansl/prog_dev/boost-svn/ro/trunk/boost/config/select_stdlib_config.hpp:33:
In file included from
/home/evansl/prog_dev/boost-svn/ro/trunk/boost/config/no_tr1/utility.hpp:21:
In file included from /usr/include/c++/4.4/utility:62:
In file included from /usr/include/c++/4.4/bits/stl_pair.h:60:
In file included from /usr/include/c++/4.4/bits/move.h:38:
In file included from /usr/include/c++/4.4/type_traits:50:
/usr/include/c++/4.4/tr1_impl/type_traits:233:29: error: type qualifier
is not allowed on this function
    struct is_function<_Res(_ArgTypes...) const>
                            ^
/usr/include/c++/4.4/tr1_impl/type_traits:233:12: error: redefinition of
'is_function<type-parameter-0-0
      (type-parameter-0-1...)>'
    struct is_function<_Res(_ArgTypes...) const>
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/4.4/tr1_impl/type_traits:227:12: note: previous
definition is here
    struct is_function<_Res(_ArgTypes...)>
           ^
/usr/include/c++/4.4/tr1_impl/type_traits:236:29: error: type qualifier
is not allowed on this function
    struct is_function<_Res(_ArgTypes......) const>
                            ^
/usr/include/c++/4.4/tr1_impl/type_traits:236:12: error: redefinition of
'is_function<type-parameter-0-0
      (type-parameter-0-1..., ...)>'
    struct is_function<_Res(_ArgTypes......) const>
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/4.4/tr1_impl/type_traits:230:12: note: previous
definition is here
    struct is_function<_Res(_ArgTypes......)>
           ^
/usr/include/c++/4.4/tr1_impl/type_traits:239:29: error: type qualifier
is not allowed on this function
    struct is_function<_Res(_ArgTypes...) volatile>

Clang has recently gotten much-improved support for the upcoming
C++0x standard. In particular, top-of-tree Clang now supports a
number of C++0x features:

  - Rvalue references (including rvalue references for *this)
  - Variadic templates
  - Inline namespaces
  - Late-specified return types
  - Decltype

You can turn on C++0x support with the -std=gnu++0x (or, if you want
to be more pedantic, -std=c++0x).

Give it a spin, write some tests, try it out with libc++, and tell
us how it went!

Thanks Doug.

It worked fine with:

template<typename... T>
struct A
{
    static unsigned const size=sizeof...(T);
};

int main(void)
{
    return A<int,int,int>::size;
}

So I tried the TestVariantBinary.cpp code found in:

  variant_compare.zip

found here:

http://www.boostpro.com/vault/index.php?&direction=0&order=&directory=Data%20Structures

however, that produced compile-time errors as shown below.
What should I do to workaround those errors?

TIA.

-regards,
Larry

/home/evansl/download/llvm/svn/build/Debug+Asserts/bin/clang -c
-std=c++0x
-I/home/evansl/prog_dev/boost-svn/ro/sandbox/rw/variadic_templates/libs/composite_storage/sandbox/pack/variant_compare/ppboost
-I/home/evansl/prog_dev/boost-svn/ro/sandbox/ro/switch
-I/home/evansl/prog_dev/boost-svn/ro/trunk -DTEMPLATE_DEPTH=300
TestVariantBinary.cpp -MMD -o
/home/evansl/prog_dev/boost-svn/ro/trunk/sandbox-local/build/clang/boost-svn/ro/sandbox/rw/variadic_templates/libs/composite_storage/sandbox/pack/variant_compare/TestVariantBinary.o

In file included from TestVariantBinary.cpp:33:
In file included from
/home/evansl/prog_dev/boost-svn/ro/trunk/boost/mpl/vector.hpp:19:
In file included from
/home/evansl/prog_dev/boost-svn/ro/trunk/boost/mpl/aux_/na.hpp:17:
In file included from
/home/evansl/prog_dev/boost-svn/ro/trunk/boost/mpl/bool.hpp:17:
In file included from
/home/evansl/prog_dev/boost-svn/ro/trunk/boost/mpl/bool_fwd.hpp:17:
In file included from
/home/evansl/prog_dev/boost-svn/ro/trunk/boost/mpl/aux_/adl_barrier.hpp:17:
In file included from
/home/evansl/prog_dev/boost-svn/ro/trunk/boost/mpl/aux_/config/adl.hpp:17:
In file included from
/home/evansl/prog_dev/boost-svn/ro/trunk/boost/mpl/aux_/config/msvc.hpp:19:
In file included from
/home/evansl/prog_dev/boost-svn/ro/trunk/boost/config.hpp:40:
In file included from
/home/evansl/prog_dev/boost-svn/ro/trunk/boost/config/select_stdlib_config.hpp:33:
In file included from
/home/evansl/prog_dev/boost-svn/ro/trunk/boost/config/no_tr1/utility.hpp:21:
In file included from /usr/include/c++/4.4/utility:62:
In file included from /usr/include/c++/4.4/bits/stl_pair.h:60:
In file included from /usr/include/c++/4.4/bits/move.h:38:
In file included from /usr/include/c++/4.4/type_traits:50:
/usr/include/c++/4.4/tr1_impl/type_traits:233:29: error: type qualifier
is not allowed on this function
    struct is_function<_Res(_ArgTypes...) const>
                            ^
/usr/include/c++/4.4/tr1_impl/type_traits:233:12: error: redefinition of
'is_function<type-parameter-0-0
      (type-parameter-0-1...)>'
    struct is_function<_Res(_ArgTypes...) const>
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/4.4/tr1_impl/type_traits:227:12: note: previous
definition is here
    struct is_function<_Res(_ArgTypes...)>
           ^
/usr/include/c++/4.4/tr1_impl/type_traits:236:29: error: type qualifier
is not allowed on this function
    struct is_function<_Res(_ArgTypes......) const>
                            ^
/usr/include/c++/4.4/tr1_impl/type_traits:236:12: error: redefinition of
'is_function<type-parameter-0-0
      (type-parameter-0-1..., ...)>'
    struct is_function<_Res(_ArgTypes......) const>
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/4.4/tr1_impl/type_traits:230:12: note: previous
definition is here
    struct is_function<_Res(_ArgTypes......)>
           ^
/usr/include/c++/4.4/tr1_impl/type_traits:239:29: error: type qualifier
is not allowed on this function
    struct is_function<_Res(_ArgTypes...) volatile>

...

Just #including iostream causes problems, as shown by
compile of the following test.cpp:

  #include <iostream>
  int main(void)
  {
    std::cout<<"Hello World!\n";
    return 0;
  }

which produces errors:

make -f clang.mk
uname -a
Linux evansl-desktop 2.6.32-24-generic #41-Ubuntu SMP Thu Aug 19
01:38:40 UTC 2010 x86_64 GNU/Linux
/home/evansl/download/llvm/svn/build/Debug+Asserts/bin/clang -c
-std=c++0x -v -c test.cpp
clang version 2.9 (trunk 124525)
Target: x86_64-unknown-linux-gnu
Thread model: posix
"/home/evansl/download/llvm/svn/build/Debug+Asserts/bin/clang" -cc1
-triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free
-main-file-name test.cpp -mrelocation-model static -mdisable-fp-elim
-masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64
-target-linker-version 2.20.1 -v -resource-dir
/home/evansl/download/llvm/svn/build/Debug+Asserts/bin/../lib/clang/2.9
-std=c++0x -ferror-limit 19 -fmessage-length 116 -fexceptions
-fgnu-runtime -fdiagnostics-show-option -o test.o -x c++ test.cpp
clang -cc1 version 2.9 based upon llvm 2.9svn hosted on
x86_64-unknown-linux-gnu
ignoring nonexistent directory "/usr/include/c++/4.4/i486-linux-gnu/64"
ignoring nonexistent directory "/usr/include/c++/4.3"
ignoring nonexistent directory "/usr/include/c++/4.3/x86_64-linux-gnu/"
ignoring nonexistent directory "/usr/include/c++/4.3/backward"
ignoring nonexistent directory "/usr/include/c++/4.3"
ignoring nonexistent directory "/usr/include/c++/4.3/i486-linux-gnu/64"
ignoring nonexistent directory "/usr/include/c++/4.3/backward"
ignoring nonexistent directory "/usr/include/c++/4.3"
ignoring nonexistent directory "/usr/include/c++/4.3/arm-linux-gnueabi/"
ignoring nonexistent directory "/usr/include/c++/4.3/backward"
ignoring nonexistent directory "/usr/include/c++/4.2"
ignoring nonexistent directory "/usr/include/c++/4.2/x86_64-linux-gnu/"
ignoring nonexistent directory "/usr/include/c++/4.2/backward"
ignoring nonexistent directory "/usr/include/c++/4.2"
ignoring nonexistent directory "/usr/include/c++/4.2/i486-linux-gnu/64"
ignoring nonexistent directory "/usr/include/c++/4.2/backward"
ignoring nonexistent directory "/usr/include/c++/4.1"
ignoring nonexistent directory "/usr/include/c++/4.1/x86_64-linux-gnu/"
ignoring nonexistent directory "/usr/include/c++/4.1/backward"
ignoring nonexistent directory "/usr/include/c++/4.1"
ignoring nonexistent directory "/usr/include/c++/4.1/i486-linux-gnu/64"
ignoring nonexistent directory "/usr/include/c++/4.1/backward"
ignoring nonexistent directory "/usr/include/c++/4.5.1"
ignoring nonexistent directory "/usr/include/c++/4.5.1/x86_64-redhat-linux/"
ignoring nonexistent directory "/usr/include/c++/4.5.1/backward"
ignoring nonexistent directory "/usr/include/c++/4.5.1"
ignoring nonexistent directory "/usr/include/c++/4.5.1/i686-redhat-linux/"
ignoring nonexistent directory "/usr/include/c++/4.5.1/backward"
ignoring nonexistent directory "/usr/include/c++/4.4.4"
ignoring nonexistent directory "/usr/include/c++/4.4.4/x86_64-redhat-linux/"
ignoring nonexistent directory "/usr/include/c++/4.4.4/backward"
ignoring nonexistent directory "/usr/include/c++/4.4.4"
ignoring nonexistent directory "/usr/include/c++/4.4.4/i686-redhat-linux/"
ignoring nonexistent directory "/usr/include/c++/4.4.4/backward"
ignoring nonexistent directory "/usr/include/c++/4.4.3/x86_64-redhat-linux/"
ignoring nonexistent directory "/usr/include/c++/4.4.3/i686-redhat-linux/"
ignoring nonexistent directory "/usr/include/c++/4.4.2"
ignoring nonexistent directory "/usr/include/c++/4.4.2/x86_64-redhat-linux/"
ignoring nonexistent directory "/usr/include/c++/4.4.2/backward"
ignoring nonexistent directory "/usr/include/c++/4.4.2"
ignoring nonexistent directory "/usr/include/c++/4.4.2/i686-redhat-linux/"
ignoring nonexistent directory "/usr/include/c++/4.4.2/backward"
ignoring nonexistent directory "/usr/include/c++/4.4.1"
ignoring nonexistent directory "/usr/include/c++/4.4.1/x86_64-redhat-linux/"
ignoring nonexistent directory "/usr/include/c++/4.4.1/backward"
ignoring nonexistent directory "/usr/include/c++/4.4.1"
ignoring nonexistent directory "/usr/include/c++/4.4.1/i586-redhat-linux/"
ignoring nonexistent directory "/usr/include/c++/4.4.1/backward"
ignoring nonexistent directory "/usr/include/c++/4.3.2"
ignoring nonexistent directory "/usr/include/c++/4.3.2/x86_64-redhat-linux/"
ignoring nonexistent directory "/usr/include/c++/4.3.2/backward"
ignoring nonexistent directory "/usr/include/c++/4.3.2"
ignoring nonexistent directory "/usr/include/c++/4.3.2/i386-redhat-linux/"
ignoring nonexistent directory "/usr/include/c++/4.3.2/backward"
ignoring nonexistent directory "/usr/include/c++/4.3.0"
ignoring nonexistent directory "/usr/include/c++/4.3.0/x86_64-redhat-linux/"
ignoring nonexistent directory "/usr/include/c++/4.3.0/backward"
ignoring nonexistent directory "/usr/include/c++/4.3.0"
ignoring nonexistent directory "/usr/include/c++/4.3.0/i386-redhat-linux/"
ignoring nonexistent directory "/usr/include/c++/4.3.0/backward"
ignoring nonexistent directory "/usr/include/c++/4.1.2"
ignoring nonexistent directory "/usr/include/c++/4.1.2/x86_64-redhat-linux/"
ignoring nonexistent directory "/usr/include/c++/4.1.2/backward"
ignoring nonexistent directory "/usr/include/c++/4.1.2"
ignoring nonexistent directory "/usr/include/c++/4.1.2/i386-redhat-linux/"
ignoring nonexistent directory "/usr/include/c++/4.1.2/backward"
ignoring nonexistent directory "/usr/include/c++/4.4.3/x86_64-pc-linux-gnu/"
ignoring nonexistent directory "/usr/include/c++/4.4.3/i686-pc-linux-gnu/"
ignoring nonexistent directory "/usr/include/c++/4.3"
ignoring nonexistent directory "/usr/include/c++/4.3/i586-suse-linux/"
ignoring nonexistent directory "/usr/include/c++/4.3/backward"
ignoring nonexistent directory "/usr/include/c++/4.3"
ignoring nonexistent directory "/usr/include/c++/4.3/x86_64-suse-linux/"
ignoring nonexistent directory "/usr/include/c++/4.3/backward"
ignoring nonexistent directory "/usr/include/c++/4.4/i586-suse-linux/"
ignoring nonexistent directory "/usr/include/c++/4.4/x86_64-suse-linux/"
ignoring nonexistent directory "/usr/include/c++/4.5"
ignoring nonexistent directory "/usr/include/c++/4.5/i586-suse-linux/"
ignoring nonexistent directory "/usr/include/c++/4.5/backward"
ignoring nonexistent directory "/usr/include/c++/4.5"
ignoring nonexistent directory "/usr/include/c++/4.5/x86_64-suse-linux/"
ignoring nonexistent directory "/usr/include/c++/4.5/backward"
ignoring nonexistent directory "/usr/include/c++/4.3.1"
ignoring nonexistent directory "/usr/include/c++/4.3.1/i686-pc-linux-gnu/"
ignoring nonexistent directory "/usr/include/c++/4.3.1/backward"
ignoring nonexistent directory "/usr/include/c++/4.3.1"
ignoring nonexistent directory
"/usr/include/c++/4.3.1/x86_64-unknown-linux-gnu/"
ignoring nonexistent directory "/usr/include/c++/4.3.1/backward"
ignoring nonexistent directory
"/usr/lib/gcc/i686-pc-linux-gnu/4.4.3/include/g++-v4"
ignoring nonexistent directory
"/usr/lib/gcc/i686-pc-linux-gnu/4.4.3/include/g++-v4/i686-pc-linux-gnu/"
ignoring nonexistent directory
"/usr/lib/gcc/i686-pc-linux-gnu/4.4.3/include/g++-v4/backward"
ignoring nonexistent directory
"/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4"
ignoring nonexistent directory
"/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/i686-pc-linux-gnu/"
ignoring nonexistent directory
"/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/backward"
ignoring nonexistent directory
"/usr/lib/gcc/i686-pc-linux-gnu/4.3.2/include/g++-v4"
ignoring nonexistent directory
"/usr/lib/gcc/i686-pc-linux-gnu/4.3.2/include/g++-v4/i686-pc-linux-gnu/"
ignoring nonexistent directory
"/usr/lib/gcc/i686-pc-linux-gnu/4.3.2/include/g++-v4/backward"
ignoring nonexistent directory
"/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include/g++-v4"
ignoring nonexistent directory
"/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include/g++-v4/i686-pc-linux-gnu/"
ignoring nonexistent directory
"/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include/g++-v4/backward"
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.5/include/g++-v4"
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.5/include/g++-v4/x86_64-pc-linux-gnu/"
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.5/include/g++-v4/backward"
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.4/include/g++-v4"
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.4/include/g++-v4/x86_64-pc-linux-gnu/"
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.4/include/g++-v4/backward"
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.3/include/g++-v4"
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.3/include/g++-v4/x86_64-pc-linux-gnu/"
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.3/include/g++-v4/backward"
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/include/g++-v4"
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/include/g++-v4/x86_64-pc-linux-gnu/"
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/include/g++-v4/backward"
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2/include/g++-v4"
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2/include/g++-v4/i686-pc-linux-gnu/"
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2/include/g++-v4/backward"
ignoring nonexistent directory
"/usr/lib/llvm-gcc-4.2-9999/include/c++/4.2.1"
ignoring nonexistent directory
"/usr/lib/llvm-gcc-4.2-9999/include/c++/4.2.1/x86_64-pc-linux-gnu/"
ignoring nonexistent directory
"/usr/lib/llvm-gcc-4.2-9999/include/c++/4.2.1/backward"
ignoring duplicate directory "/usr/include/c++/4.4"
ignoring duplicate directory "/usr/include/c++/4.4/backward"
ignoring duplicate directory "/usr/include/c++/4.4"
ignoring duplicate directory "/usr/include/c++/4.4/backward"
ignoring duplicate directory "/usr/include/c++/4.4"
ignoring duplicate directory "/usr/include/c++/4.4/backward"
ignoring duplicate directory "/usr/include/c++/4.4"
ignoring duplicate directory "/usr/include/c++/4.4/backward"
ignoring duplicate directory "/usr/include/c++/4.4"
ignoring duplicate directory "/usr/include/c++/4.4/backward"
ignoring duplicate directory "/usr/include/c++/4.4"
ignoring duplicate directory "/usr/include/c++/4.4/backward"
ignoring duplicate directory "/usr/include/c++/4.4"
ignoring duplicate directory "/usr/include/c++/4.4/backward"
#include "..." search starts here:
#include <...> search starts here:
/usr/include/c++/4.4
/usr/include/c++/4.4/x86_64-linux-gnu
/usr/include/c++/4.4/backward
/usr/local/include
/home/evansl/download/llvm/svn/build/Debug+Asserts/bin/../lib/clang/2.9/include
/usr/include
End of search list.
In file included from test.cpp:1:
In file included from /usr/include/c++/4.4/iostream:39:
In file included from /usr/include/c++/4.4/ostream:39:
In file included from /usr/include/c++/4.4/ios:39:
In file included from /usr/include/c++/4.4/exception:148:
/usr/include/c++/4.4/exception_ptr.h:143:13: error: unknown type name
'type_info'
      const type_info*
            ^
In file included from test.cpp:1:
In file included from /usr/include/c++/4.4/iostream:39:
In file included from /usr/include/c++/4.4/ostream:39:
In file included from /usr/include/c++/4.4/ios:40:
In file included from /usr/include/c++/4.4/bits/char_traits.h:40:
In file included from /usr/include/c++/4.4/bits/stl_algobase.h:66:
In file included from /usr/include/c++/4.4/bits/stl_pair.h:60:
In file included from /usr/include/c++/4.4/bits/move.h:38:
In file included from /usr/include/c++/4.4/type_traits:50:
/usr/include/c++/4.4/tr1_impl/type_traits:233:29: error: type qualifier
is not allowed on this function
    struct is_function<_Res(_ArgTypes...) const>

[snip]

Just #including iostream causes problems, as shown by
compile of the following test.cpp:

  #include <iostream>
  int main(void)
  {
    std::cout<<"Hello World!\n";
    return 0;
  }

which produces errors:

make -f clang.mk
uname -a
Linux evansl-desktop 2.6.32-24-generic #41-Ubuntu SMP Thu Aug 19
01:38:40 UTC 2010 x86_64 GNU/Linux
/home/evansl/download/llvm/svn/build/Debug+Asserts/bin/clang -c
-std=c++0x -v -c test.cpp
clang version 2.9 (trunk 124525)
Target: x86_64-unknown-linux-gnu

[snip]
Without the -std=c++0x, it compiles fine:

make -f clang.mk
/home/evansl/download/llvm/svn/build/Debug+Asserts/bin/clang -c test.cpp

Compilation finished at Sat Jan 29 13:17:42

The problem you are seeing is that adding -std=c++0x adds a bunch of new g++-specific extensions to libstdc++ (the g++ standard library implementation). To make clang work on linux these all need supporting (or libc++ needs porting over).

Chris

Clang has recently gotten much-improved support for the upcoming
C++0x standard.

[snip]

Just #including iostream causes problems, as shown by
compile of the following test.cpp:

#include <iostream>
int main(void)
{
   std::cout<<"Hello World!\n";
   return 0;
}

The problem you are seeing is that adding -std=c++0x adds a bunch of new g++-specific
extensions to libstdc++ (the g++ standard library implementation). To make clang work
on linux these all need supporting (or libc++ needs porting over).

Chris

Thanks Chris,

Using the compile option, -U__GXX_EXPERIMENTAL_CXX0X__, seems to
workaround the compile problem. However, I've not tried linking yet.

Larry

Clang has recently gotten much-improved support for the upcoming
C++0x standard.

[snip]

Just #including iostream causes problems, as shown by
compile of the following test.cpp:

#include <iostream>
int main(void)
{
   std::cout<<"Hello World!\n";
   return 0;
}

The problem you are seeing is that adding -std=c++0x adds a bunch of new g++-specific
extensions to libstdc++ (the g++ standard library implementation). To make clang work
on linux these all need supporting (or libc++ needs porting over).

Chris

Thanks Chris,

Using the compile option, -U__GXX_EXPERIMENTAL_CXX0X__, seems to
workaround the compile problem. However, I've not tried linking yet.

Larry

Linking fails with:

/home/evansl/download/llvm/svn/build/Debug+Asserts/bin/clang -v test.o
-o test.x
clang version 2.9 (trunk 124525)
Target: x86_64-unknown-linux-gnu
Thread model: posix
"/usr/bin/ld" -z relro --hash-style=both --build-id --eh-frame-hdr -m
elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o test.x
/usr/lib/gcc/x86_64-linux-gnu/4.4.3/../../../../lib64/crt1.o
/usr/lib/gcc/x86_64-linux-gnu/4.4.3/../../../../lib64/crti.o
/usr/lib/gcc/x86_64-linux-gnu/4.4.3/crtbegin.o
-L/usr/lib/gcc/x86_64-linux-gnu/4.4.3
-L/usr/lib/gcc/x86_64-linux-gnu/4.4.3/../../../../lib64 -L/lib/../lib64
-L/usr/lib/../lib64 -L/usr/lib/gcc/x86_64-linux-gnu/4.4.3/../../..
-L/usr/lib/x86_64-linux-gnu test.o -lgcc --as-needed -lgcc_s
--no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed
/usr/lib/gcc/x86_64-linux-gnu/4.4.3/crtend.o
/usr/lib/gcc/x86_64-linux-gnu/4.4.3/../../../../lib64/crtn.o
test.o: In function `__cxx_global_var_init':
test.cpp:(.text+0xc): undefined reference to `std::ios_base::Init::~Init()'
test.cpp:(.text+0x30): undefined reference to `std::ios_base::Init::Init()'
test.o: In function `main':
test.cpp:(.text+0x69): undefined reference to `std::cout'
test.cpp:(.text+0x81): undefined reference to
`std::ostream::operator<<(unsigned int)'
test.cpp:(.text+0x8d): undefined reference to `std::basic_ostream<char,
std::char_traits<char> >& std::operator<< <std::char_traits<char>

(std::basic_ostream<char, std::char_traits<char> >&, char const*)'

clang: error: linker command failed with exit code 1 (use -v to see
invocation)
make: *** [test] Error 1

Compilation exited abnormally with code 2 at Sun Jan 30 06:26:12

Presumable there's some link option I could pass to tell clang
where to find main?

-Larry