c++ - Eclipse C.D.T. can't recognize standard functions or "NULL" -
i have been having problem weeks , have not been able find solution.
when trying use eclipse or trying compile plain gcc or g++ through terminal, there number of standard functions (plus "null" variable) not recognized, including to_string method.
i have attempted add many different headers program in attempt find correct files, no avail. have tried #including <string>, <stdio.h>, <stddef.h>, <cstdlib>, , pretty other standard header find in forum posts might contain to_string function. tried of these #includes , without ".h" extension. still, not matter tried, to_string , null not recognized (among other methods).
i've been through many forums , many forum posts , tried many solutions, including this one, this one, this one, this one, this one, , more. still, have found no solution.
i have tried uninstalling , reinstalling eclipse c.d.t., eclipse whole, gcc, , g++. have tried adding -std=c++11 and/or -std=c++99 flags gcc command or g++ command. have tried building in eclipse linux gcc, cross gcc, , other versions of gcc.
i running eclipse 3.8 both j.d.t. , c.d.t. packages installed on 64-bit linux mint 16 petra.
if me resolve issue, "grateful" not express gratitude toward you.
edit: here 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 sample of code code having errors. please keep in mind have attempted add other #includes not shown , have reason believe missing #include not 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: summary of comments below have determined cause eclipse not recognizing c++11 standard functions , keywords. installed netbeans on system c/c++ plugin , exact same errors occurring. can't seem netbeans or eclipse recognize c++11 features despite adding -std=c++11 flag in multiple places in project configurations.
as of right now, eclipse can compile without giving c++11 errors; however, in code window, c++11 functions , features still marked errors red underline, issue still not resolved. need tell me how eclispe and/or netbeans recognize c++11 features in error parsers.
thanks again in advance may able provide.
try compile source code with
g++ -std=c++11 ... according to_string(), c++ 2011 feature.
in eclipse kepler, set selecting
project >> properties >> c/c++ build >> settings >> tool settings >> gcc c++ compiler >> dialect
and choosing iso c++11 (-std=c++0x) language standard.
and should choose [all configurations] configuration @ c/c++ build.
Comments
Post a Comment