The following is my environment:
- Eclipse IDE for C/C++ Developers(Juno)
- Qt 4.8.3
- Qt Eclipse Integration v1.6.1
- mingw(20120426)
When I create a Qt console project, I just can’t use C library functions, such as exit(int) or atoi(string).
The error message is such like Function 'exit' could not be resolved.
I have included stdlib.h, but still can’t work.
I don’t know if there is some relation with index.
20121109 Update
Thanks for give me help!
atoi is just a example!
Although I write program in c++, but sometimes I want use C library, so I tag it c++.
The following is what I include
C:/MinGW/includeC:/MinGW/lib/gcc/mingw32/4.6.2/includeC:/MinGW/lib/gcc/mingw32/4.6.2/include/c++C:/MinGW/lib/gcc/mingw32/4.6.2/include/c++/backwardC:/MinGW/lib/gcc/mingw32/4.6.2/include/c++/mingw32C:/MinGW/lib/gcc/mingw32/4.6.2/include-fixed
Others are Qt library.
And the following is main.
#include <QtCore>
#include <QCoreApplication>
#include <cstdlib>
using namespace std;
int main(int argc, char *argv[])
{
std::exit(0);
QCoreApplication a(argc, argv);
return a.exec();
}
I try this way but still get error message Function 'exit' could not be resolved.
Thanks a lot!
First of all, use C++ headers style. For stdlib.h :
Then, I guess you’re not bringing namespace information. Either write :
(even if I don’t recommend it) or
or use fully qualified names :
Finally, why do you need such functions like atoi ?