How to enable C++11 in PNaCl?

241 views
Skip to first unread message

Alan Ide

unread,
May 24, 2013, 12:01:21 PM5/24/13
to native-cli...@googlegroups.com
I have been reading through all the posts and have found that PNaCl should be able to compile "some" c++11 features. However when I add the following line to the Makefile:

CXXFLAGS:=-std=c++0x


The compiler still spits out:

/Developer/nacl_sdk/pepper_canary/toolchain/mac_x86_pnacl/newlib/usr/include/c++/4.6.2/bits/c++0x_warning.h:32:2: error: This file requires compiler and library support for the upcoming ISO C++ standard, C++0x. This support is currently experimental, and must be enabled with the -std=c++0x or -std=gnu++0x compiler options.


Thoughts?

Derek Schuff

unread,
May 28, 2013, 7:01:50 PM5/28/13
to native-cli...@googlegroups.com
I believe that that particular warning is what you get when you include certain headers from c++11.

Currently PNaCl's C++ compiler is based on clang/llvm 3.3, which has pretty good C++11 support. however the C++ standard library is still based on gcc's libstdc++ 4.6, which is fairly old (and IIRC from before C++11 was officially standardized/named; hence the message referring to c++0x rather than c++11). For now you should be able to use C++11 language features (e.g. auto, range-based for), but until we update the standard library (which should be soon but probably not for the very first release), you'll get these warnings and C++11 features which require standard library support may or may not work.



--
You received this message because you are subscribed to the Google Groups "Native-Client-Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to native-client-di...@googlegroups.com.
To post to this group, send email to native-cli...@googlegroups.com.
Visit this group at http://groups.google.com/group/native-client-discuss?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Alan Ide

unread,
May 28, 2013, 7:57:30 PM5/28/13
to native-cli...@googlegroups.com
Thanks for the info. I look forward to the future updates.

Victor Khimenko

unread,
May 28, 2013, 8:13:29 PM5/28/13
to Native Client Discuss
On Wed, May 29, 2013 at 3:57 AM, Alan Ide <al...@digitalsynapses.com> wrote:
Thanks for the info. I look forward to the future updates.

I've took a look on this issue. libstdc++ 4.6 expects to see __GXX_EXPERIMENTAL_CXX0X__ defined but in GCC 4.7+ it was changed to check value of __cplusplus (it must be >= 201103L as standard requires). I think you should be able to use at least some features if you'll use "-std=c++0x -D__GXX_EXPERIMENTAL_CXX0X__=1" combination to fix this impedance. You will probably not be able to use features which need support in prebuilt library, but most STL-provided freatures are templates and thus will be inlined if you'll use -O2 switch.

张华

unread,
Sep 29, 2015, 5:02:06 AM9/29/15
to Native-Client-Discuss
Use flag -std=gnu++11

Derek Schuff

unread,
Sep 29, 2015, 12:23:30 PM9/29/15
to Native-Client-Discuss
What version of the SDK are you using? PNaCl hasn't used libstdc++ (which is the path you are seeing) in a long time. You can update to a recent SDK, or (depending on which version of the SDK you have) you can try the -stdlib=libc++ flag 

--
You received this message because you are subscribed to the Google Groups "Native-Client-Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to native-client-di...@googlegroups.com.
To post to this group, send email to native-cli...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages