clang++ C++11 invocation

22,712

ildjarn points out the correct argument, -std=c++0x or -std=c++11. The errors you're getting with that argument may be because the version of libstdc++ you're using uses some C++11, or non-standard C++, that clang 2.9 doesn't support.

Share:
22,712
bitmask
Author by

bitmask

I am a computer scientist, enthusiast programmer, and activist. Accept policy If you wonder why I didn't accept your answer, although it is obviously the right thing: Usually, I like to wait at least an hour before accepting anything, often I wait a day or so. More random information about me kernel: linux distro: debian interface: xmonad + mate text: vim web: firefox mail: thunderbird programming: mainly c++, some python, occasionally haskell, svg speak: de, en, es (read-only), limited support: fr, ru rcs: git scifi: The Matrix, Star Trek, Doctor Who, Firefly First to earn the the-matrix bronze badge on scifi.SE. Flair Bad Wolf

Updated on November 29, 2020

Comments

  • bitmask
    bitmask over 3 years

    Although there are some questions here concerning the C++11 support of clang, I don't seem to be able to get clang++ to eat my C++11 code.

    $ clang++ --version
    clang version 2.9 (tags/RELEASE_29/final)
    Target: x86_64-pc-linux-gnu
    Thread model: posix
    

    According to the clang C++11 status page I should have at least partial support (e.g. right angle brackets), but it refuses all features I tested.

    Is there any switch to tell clang to use C++11?


    Example test:

    $ clang++ -stdlib=libstdc++ cpp11.cpp 
    cpp11.cpp:16:33: error: a space is required between consecutive right angle brackets (use '> >')
      std::vector<std::pair<int,char>> xs;
                                    ^~
                                    > >
    cpp11.cpp:18:8: error: C++ requires a type specifier for all declarations
      auto y = x;
      ~~~~ ^
    2 errors generated