to_string is not a member of std
Posted: Fri Jun 08, 2018 8:52 am
Hello,
I apologize if this post does not belong here. I am having an issue using to_string() function while using CodeLite and MinGW GCC 8.1 64bit compiler on Windows 10.
Any help in pointing me in the right direction would be greatly appreciated as I have reached out to the GNU GCC folks with no reply as of yet.
I have a main...
I am including:
#include <stdio.h>
#include <iostream>
#include <iomanip> //This allows the manipulation of output to align correctly using setw function
#include <Conversion.h> //custom class
#include <Area.h> //custom class
#include <string.h> //gain access to string class
I am using:
using namespace std;
using namespace ErolD_DS; //my namespace for custom classes
I have a piece of code that states:
for(unsigned int i = 1; i <= 6; i++)
{
double newArea = area.CalculateArea_EqTriangle(i);
cout << "Equilateral Triangle area: " + to_string(newArea) << endl;
}
There are two errors I receive depending on using scope resolution or not (which I shouldn't have to use)...
This code above will result in a compile error: 'to_string' was not declared in this scope
However, if I use scope resolution: std::to_string(newArea), which I shouldn't have to considering I'm using std namespace, it results in the error: 'to_string' is not a member of 'std'.
I have poked around on the internet and found that, a while back this was an issue prior to GNU GCC 4.8.1 version. Here is an example: https://stackoverflow.com/questions/191 ... le_rich_qa
The fix, for me, was to put this switch in place in the c++ compiler executable from within CodeLite: -std=c++11
I shouldn't have to do this because string, as I understand it, is part of the C++ standard and has been for a time... long before this version of the compiler. It's not as if it's like PI in the math class where I have to
#define _USE_MATH_DEFINES because PI is not technically part of the C++ standard...
I understand this may not be directly related to CodeLite, but I can't seem to get an answer as to why I have to put this option in the compiler within CodeLite.
Again, any help would be appreciated.
Thanks,
-Erol
I apologize if this post does not belong here. I am having an issue using to_string() function while using CodeLite and MinGW GCC 8.1 64bit compiler on Windows 10.
Any help in pointing me in the right direction would be greatly appreciated as I have reached out to the GNU GCC folks with no reply as of yet.
I have a main...
I am including:
#include <stdio.h>
#include <iostream>
#include <iomanip> //This allows the manipulation of output to align correctly using setw function
#include <Conversion.h> //custom class
#include <Area.h> //custom class
#include <string.h> //gain access to string class
I am using:
using namespace std;
using namespace ErolD_DS; //my namespace for custom classes
I have a piece of code that states:
for(unsigned int i = 1; i <= 6; i++)
{
double newArea = area.CalculateArea_EqTriangle(i);
cout << "Equilateral Triangle area: " + to_string(newArea) << endl;
}
There are two errors I receive depending on using scope resolution or not (which I shouldn't have to use)...
This code above will result in a compile error: 'to_string' was not declared in this scope
However, if I use scope resolution: std::to_string(newArea), which I shouldn't have to considering I'm using std namespace, it results in the error: 'to_string' is not a member of 'std'.
I have poked around on the internet and found that, a while back this was an issue prior to GNU GCC 4.8.1 version. Here is an example: https://stackoverflow.com/questions/191 ... le_rich_qa
The fix, for me, was to put this switch in place in the c++ compiler executable from within CodeLite: -std=c++11
I shouldn't have to do this because string, as I understand it, is part of the C++ standard and has been for a time... long before this version of the compiler. It's not as if it's like PI in the math class where I have to
#define _USE_MATH_DEFINES because PI is not technically part of the C++ standard...
I understand this may not be directly related to CodeLite, but I can't seem to get an answer as to why I have to put this option in the compiler within CodeLite.
Again, any help would be appreciated.
Thanks,
-Erol