5

I am trying to get some c++ code (with c++11) to compile in the mac terminal. I tried

clang++ -std=c++11 main.cpp

but i get the error

error: invalid value 'c++11' in '-std=c++11'

My xcode is completely up to date, I am assuming I am doing something wrong in the terminal? The code runs fine in xcode itself, I just cannot get it to run in the terminal. Any tips would be great!

Michael Celey
  • 12,645
  • 6
  • 57
  • 62
Nick BL
  • 363
  • 2
  • 13
  • 7
    Try `-std=c++0x` – Andy Prowl Mar 30 '13 at 17:08
  • 3
    `-std=c++11` should work with recent clang versions though. Have you updated the command line tools (needs to be done manually), see http://stackoverflow.com/questions/9329243/xcode-4-4-command-line-tools – erikced Mar 30 '13 at 17:32
  • 3
    Yep, you need to update. If it doesn't accept `c++11` it's ooold. (You might want to check with the `-v` flag.) – Potatoswatter Mar 31 '13 at 07:26

2 Answers2

1

As Andy has already said, your compiler only accepts -std=c++0x. It`s probably quite old.

[ Answering only to remove the question from unanswered question queue ]

0

i am not sure about this but in my experience, being up-to-date in Xcode might not mean that you are up-to-date in clang too, i had problem while trying to compile a c++ code using g++ on mac osx mountain lion. my xcode was latest but gcc was old (4.2.1). i had to install latest version of gcc from http://hpc.sourceforge.net (4.8.1). now it works. i use g++ -std=c++11 for compiling.

Guddu
  • 2,325
  • 2
  • 18
  • 23