I have been having this problem for weeks and have not been able to find a solution.
When trying to use Eclipse or trying to compile with plain GCC or G++ through a terminal, there are a number of standard functions (plus the "NULL" variable) that are not recognized, including the to_string method.
I have attempted to add many different headers to the program in an attempt to find the correct files, but to no avail. I have tried #including <string>, <stdio.h>, <stddef.h>, <cstdlib>
, and pretty much any other standard header I could find in forum posts that might contain the to_String function. I even tried all of these #includes with AND without the ".h" extension. Still, not matter what I tried, to_string and NULL were not recognized (among other methods).
I've been through many forums and many forum posts and tried many solutions, including this one, this one, this one, this one, this one, and more. Still, I have found no solution.
I have tried uninstalling and reinstalling Eclipse C.D.T., Eclipse as a whole, GCC, and G++. I have tried adding -std=c++11 and/or -std=c++99 flags to the GCC command or g++ command. I have tried building in Eclipse with Linux GCC, Cross GCC, and other versions of GCC.
I am running Eclipse 3.8 with both J.D.T. and C.D.T. packages installed on 64-bit Linux Mint 16 Petra.
If anyone could help me resolve this issue, "grateful" would not properly express my gratitude toward you.
EDIT:
Here is the output of gcc -v
:
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.8/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.8.1-10ubuntu9' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.8 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.8.1 (Ubuntu/Linaro 4.8.1-10ubuntu9)
Here's a sample of the code the code that is having errors. Please keep in mind that I have attempted to add other #includes not currently shown and I have reason to believe that a missing #include is not the problem.
#include <string>
#include <stdio.h>
#include <iostream>
using namespace std;
int Month[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
string x;
class Date_Time {
private:
int minute, hour, day, month, year;
public:
Date_Time(int minute, int hour, int day, int month, int year) {
this->minute = minute;
this->hour = hour;
this->day = day;
this->month = month;
this->year = year;
}
string toString() {
string min = to_string(minute);
if (min.length() == 1)
min = '0' + min;
return to_string(month) + "/" + to_string(day) + "/" + to_string(year)
+ " " + to_string(hour) + ":" + min;
}
void addMinutes(int min) {
minute = min + minute;
if (minute > 59) {
minute = minute - 60;
hour = hour + 1;
}
if (hour > 24) {
hour = hour - 24;
day = day + 1;
}
if (day > Month[month])
day = day - Month[month];
month = month + 1;
if (month > 12) {
month = 1;
year = year + 1;
}
}
int getYear() {
return year;
}
int getMonth() {
return month;
}
int getDay() {
return day;
}
int getHour() {
return hour;
}
int getMinutes() {
return minute;
}
};
EDIT: The summary of the comments below is that we have determined that the cause is that Eclipse is not recognizing C++11 standard functions and keywords. I installed NetBeans on my system with their C/C++ plugin and the exact same errors are occurring. I can't seem to get NetBeans or Eclipse to recognize C++11 features despite adding the -std=c++11
flag in multiple places in the project configurations.
As of right now, Eclipse can finally compile without giving C++11 errors; however, in the code window, C++11 functions and features are still marked as errors with a red underline, so the issue is still not completely resolved. All I need is for someone to tell me how to get Eclispe and/or NetBeans to recognize C++11 features in its error parsers.
Thanks again in advance for any help you may be able to provide.