c++11google-nativeclient

Use C++11 with NaCl/PNaCl


I want test NaCl and PNaCl(next, I will use NaCL for both) with default SDK and Pepper_31.

https://developers.google.com/native-client/dev/

I try adapt a old project, but this project use C++11. I add to CFLAGS this option -std=c++11, but this option is unrecognized.

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

Normal, NaCl support C++11, but maybe i don't understand this chapter.

https://developers.google.com/native-client/dev/reference/pnacl-c-cpp-language-support#source-language-support

After some reserch to use C++11 with NaCL, a solution is use to CFLAGS this options -std=c++0x -D__GXX_EXPERIMENTAL_CXX0X__=1.

But C++11 is not completly supported and I have a lot of error (this code works with GCC 4.7.2 with -std=C++11 option).

My questions are :

1) Does NaCl support really C++11?

2) If yes, How enable C++11 with NaCl?

3) Else, this support will be released shortly(Pepper_32 maybe)?

4) Have you others soltutions?

Thank for your attention.

edit: When I compil with default toolchain with -std=c++0x -D__GXX_EXPERIMENTAL_CXX0X__=1 as option, it result this error :

src/GEP_PARSE/ParserCSV.cpp: In function 'void csvWriteFile(std::vector, std::allocator >, std::allocator, std::allocator> > >, std::allocator, std::allocator >, std::allocator, std::allocator > > > > >&, const std::string&, char)':

src/GEP_PARSE/ParserCSV.cpp:16: error: expected initializer before ':' token src/GEP_PARSE/ParserCSV.cpp:24: error: expected primary-expression before '}' token src/GEP_PARSE/ParserCSV.cpp:24: error: expected ';' before '}' token src/GEP_PARSE/ParserCSV.cpp:24: error: expected primary-expression before '}' token src/GEP_PARSE/ParserCSV.cpp:24: error: expected ')' before '}' token src/GEP_PARSE/ParserCSV.cpp:24: error: expected primary-expression before '}' token src/GEP_PARSE/ParserCSV.cpp:24: error: expected ';' before '}' token

Makefile:24: recipe for target 'newlib/Release/src/GEP_PARSE/ParserCSV_x86_32.o' failed make: * [newlib/Release/src/GEP_PARSE/ParserCSV_x86_32.o] Error 1

Code source : for(auto row:record) { ... }


Solution

  • As you've found, the x86 NaCl compilers are too old for complete C++11 support:

    $ pwd
    /home/binji/dev/testsdk/nacl_sdk/pepper_31/toolchain/linux_x86_newlib/x86_64-nacl/bin
    
    $ ./gcc --version
    gcc (GCC) 4.4.3 20130827 (Native Client r12067, Git Commit 46c2b9f0e51c734569cdd6956af695881814e7ed)
    Copyright (C) 2010 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.
    

    You can compare that to this page to see which features are missing: http://gcc.gnu.org/projects/cxx0x.html

    The PNaCl compiler supports C++11, though: https://developers.google.com/native-client/dev/reference/pnacl-c-cpp-language-support

    And you can use the pnacl-translate tool to convert from a .pexe to an architecture-specific .nexe.

    Note that currently PNaCl uses GCC's libstdc++, not LLVM's libc++, though this should be fixed soon. See a recent thread here: https://groups.google.com/d/msg/native-client-discuss/WxRAMOO_6iE/TJw6O9JtIUsJ