adam, two things...
1. I don't believe that you are using 7.1.0, because 7.1.0 defaults to C++14.
If you're using 7.1.0, this should compile without having to explicitly say -std=c++11 or beyond.
1 2 3 4 5 6 7
|
#include <fstream>
#include <string>
int main()
{
std::ifstream f(std::string("test"));
}
|
However... maybe I'm wrong. Can you compile your program by command line and add -v
e.g.
g++ -v main.cpp -o main.exe |
You can also add -v as an "additional command-line argument" within Code::Blocks.
Tell us what version the output is.
For example, mine says.
C:\code\cplusplus243635>g++ -v main.cpp -o main.exe
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/x86_64-w64-mingw32/7.1.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../src/configure --enable-languages=c,c++ --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --disable-multilib --prefix=/c/temp/gcc/dest --with-sysroot=/c/temp/gcc/dest --disable-libstdcxx-pch --disable-libstdcxx-verbose --disable-nls --disable-shared --disable-win32-registry --with-tune=haswell
Thread model: win32
gcc version 7.1.0 (GCC)
COLLECT_GCC_OPTIONS='-v' '-o' 'main.exe' '-mtune=haswell' '-march=x86-64'
GNU C++14 (GCC) version 7.1.0 (x86_64-w64-mingw32) [I'm using 64-bit]
compiled by GNU C version 7.1.0, GMP version 6.1.2, MPFR version 3.1.5-p2, MPC version 1.0.3, isl version isl-0.18-GMP |
2. Earlier versions of MinGW had awful support for C++11 string-related functionality, but 7.1.0 should be fine.
EDIT: Since you said you're using 32-bit.... maybe 32-bit MinGW still has problems and isn't correctly implementing what GCC says. That's possible. In which case I don't have a solution other than not using 32-bit.
But exhaust your other options first.
When you go into compiler settings on CodeBlocks, are you sure that you're pointing the compiler to your 7.1.0 one? CodeBlocks comes with its own compiler, you want to make sure it's not using that. In fact, I would completely move the compiler directory that comes with codeblocks into the recycle bin. Then try to compile again.
3. If you're still having problems, bypass CodeBlocks completely, and just try to compile the following program via command-line:
1 2 3 4 5 6
|
#include <string>
int main()
{
std::cout << std::to_string(42) << std::endl;
}
|
g++ -v main.cpp -o main.exe |
and let us know what happens.