Issue
Good day
I have searched high and low, yet no solution.
IDE: NetBeans IDE 8.2 MinGW: Using the "latest" MinGW compiler.
Original Issue:
I would like to convert an int to string.
Using href="https://stackoverflow.com/questions/5590381/easiest-way-to-convert-int-to-string-in-c">this method, I attempted to convert to string, however
this proposed method std::to_string()
results in the error when used(with the to_string as the error)
unable to resolve identifier to_string
Project dependancies:
#include <string>
#include <iostream>
Searching for a solution to this issue, 2 promonent solutions appeared here and here
Setting the C and C++ compiler versions should apparenlty solve this issue.
It did not, any suggestions?
Minimal Code:
#include <string>
struct User_VPN_Info{
std::string name, expire;
int DaysLeft;
User_VPN_Info(){}
User_VPN_Info(std::string _name, std::string _expire, int _DaysLeft){
name = _name;
expire = _expire;
DaysLeft = _DaysLeft;
}
std::string getString(){
return(name + " + " + expire + " + " + std::to_string(DaysLeft) + " ; ");
} //^_______^ problem here
};
Solution
It is know issue with MinGW
gcc -std=gnu++14 -Wall -Wextra main.cpp main.cpp: In function 'int main()': main.cpp:24:26: error: 'to_string' was not declared in this scope cout<<to_string(a)<<endl; gcc --version gcc.exe (GCC) 5.3.0
Instant of 'standard" MinGw you should use MinGW-w64 - for 32 and 64 bit Windows
/mingw-w64/i686-6.2.0-posix-dwarf-rt_v5-rev1/mingw32/bin ./g++ -std=c++14 main.cpp
compile without errors
If you want change toolchain in Netbeans you have to add new Tool Collection in project properties.
Answered By - steff
Answer Checked By - Clifford M. (JavaFixing Volunteer)