using c++11 in Mac operating system

Hello,

I would like to use c++11 in my Mac system. Could someone show me how to install the compiler of c++11 to use g++ with the option -std=gnu++11 or g++ -std=c++0X in the terminal.
I used :
clang++ -std=gnu++11 test.cpp

but I get the error:
error: invalid value 'gnu++11' in '-std=gnu++11'


Thanks
Younès
I just use:
g++ -std=c++11 test.cpp -o test


Are you using Mavericks, by any chance? Guessing the reason the gnu flags bugger is because gcc in Mavericks actually links to Clang. If you want to use gcc you can install it using Macports or Homebrew.
Last edited on
I am using Mountain OS.
I try
g++ -std=c++11 test.cpp -o test
But the bash returns the following error:

cc1plus: error: unrecognized command line option "-std=c++11"

same for:
gcc -std=gnu++11 test.cpp

I get the error:
cc1plus: error: unrecognized command line option "-std=gnu++11"

My question relies with the installation of g++ or gcc that compiles using the standard: c++11.

Thanks
Younes
> I try
> g++ -std=c++11 test.cpp -o test

Try
clang++ -std=c++11 test.cpp -o test
You have to make sure that the version of compiler you are using supports c++11 with the
-std=c++11 or -std=gnu++11
options. For gcc compilers, you need atleast version (4.7):

g++.exe (GCC) 4.8.1
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


From this page, you can see that you need atleast version 4.7:
http://gcc.gnu.org/projects/cxx0x.html

For llvm compiler clang, you need just version 3.3 to get all the c++11 features

From http://coliru.stacked-crooked.com/
clang version 3.5 (trunk 198621)
Target: x86_64-unknown-linux-gnu
Thread model: posix


So with the just version 3.3 you have both c++11 and c++14 under your belt:
http://clang.llvm.org/cxx_status.html

EDIT: It also seems that for you to get clang on your apple product, you need xcode installed (just tried it on a mac air). So if you don't have that already, I suggest you get on it because xcode unlocks the full potential of software development on apple.
Last edited on
I don't hace c++11 in my system MacOs.
I try to enter to the pages:
http://gcc.gnu.org/projects/cxx0x.html
From http://coliru.stacked-crooked.com/

But there is no link to download c++11.

http://clang.llvm.org/get_started.html

edit:
coliru.stacked-crooked probably wont have a download link because like ideone, it is meant to just run the code and return the output to the browser
Last edited on
Topic archived. No new replies allowed.