How can I use C++11 in GNU GCC compiler in CodeBlocks? - c++11

I'm trying to use the function stoi() in a program which is a C++11 function but I can't configure my compiler to use C++11. I added the (-std=c++11) compiler flag but it didn't work. I also tried the (-std=c++0x) and it also didn't work. I also tried these options after updating the compiler to GCC 4.8 that should support C++11 and didn't work. I don't know what to do.

Related

AVX and newer intrinsics with GCC on Mac; what assembler would one need?

I have been tweaking GCC 6.3.0 to get it to use the libc++ runtime instead of libstdc++ so that g++ can be used without worrying about C++ runtime incompatibilities:
https://github.com/RJVB/macstrop/tree/master/lang/gcc6
The tweak works, I can build and run KDE software using g++ against Qt5 and KF5 frameworks (and everything else) built with various clang versions.
What doesn't work is generating code that uses AVX and presumably most or all newer intrinsic instructions.
This is not a new issue that's never been invoked on here; it's answered here for instance: How to use AVX/pclmulqdq on Mac OS X
Evidently one can configure gcc to call the linked script instead of the actual as executable.
But can gcc not be configured to use another assembler altogether, like nasm, and would that solve this issue?

g++ (tdm-1) 4.7.1 doesnt support all c++11 features

it's supposed g++ (tdm-1) 4.7.1 that comes with codeblocks for windows support all C++11 features, std::stoi(str) isnt reconized, same for other c++11 functions. (string header is included).
Do i need to look for another compiler ?
This is due to missing C library functions in MinGW, see the last few comments on https://gcc.gnu.org/bugzilla/show_bug.cgi?id=37522
I made some improvements so it is supported in MinGW GCC 4.9 and later, so you could just upgrade to a later TDM build.

Is codecvt not supported by Clang or GCC?

I can't even get the basic codecvt example from cppreference.com to compile on GCC 4.9 or Clang 3.4, e.g.:
http://goo.gl/HZ5GLH
http://coliru.stacked-crooked.com/a/345d6d89949ac1e6
According to libstdc++ manual, part 22.4.1, it is missing the support for codecvt, even on the latest version.
And libc++ has complete support for C++11 and C++14 features, so you should use it on CLang, specifying the -stdlib=libc++ compiler flag (make sure you have it installed).
Edit: As of current versions of libstdc++, codecvt is now supported.

about clang++ requirements for C++11

I would like to build some code in new C++11. Our machine allows only g++4.4.7 that is old for that. We have available also clang++ 3.4 that as far as I understood supports the new features.
While I am doing first tests with clang++ it looks like it does requires c++ header files from g++. Having available version g++4.4 this will prevent my code to use the new C++11.
Is it really so? Is there a way where I can use clang++3.4 to build C++11 code without having latest versions of g++ ?
Try libc++, on linux should work just fine
http://libcxx.llvm.org/

Set as default C++11 in Clang

The LLVM C++ compiler has full support for C++11 standard. Is there a way to set C++11 as the default standard without adding -std=c++11 compiler flag every time? I tried setting CCXFLAGS environment variable to -std=c++11, but with no luck.
Use clang 6.0.0 or higher. The default C++ dialect is now C++14.
http://releases.llvm.org/6.0.1/tools/clang/docs/ReleaseNotes.html#c-language-changes-in-clang

Resources