PDA

View Full Version : General C++ exception not working with QT Necessitas



blackrue2000
15th August 2012, 19:54
Could someone tell me how to handle exceptions with a QT necessitas mobile app. I have Math app that throws an exception if something is divided by zero. The code works perfectly on QT SDK for windows but when I run the program on necessitas the app always crashes. Why can't I throw an exception? Remember this code works fine on QT SDK, when I use Necessitas QT SDK the app crashes.

try
{
//Throw exception if divide by zero
if ((terms[0] == 0) || (terms[3]== 0) || (terms[6] == 0) || ((terms[9]-terms[11])== 0 ) || ((terms[12]+terms[14])== 0 ))
throw "Cannot divide by 0 term";


this->answerline1->setText(QString::number(((terms[1]+terms[2])/terms[0])));
this->answerline2->setText(QString::number(((terms[4]-terms[5])/terms[3])));
this->answerline3->setText(QString::number(((terms[7]*terms[8])/terms[6])));
this->answerline4->setText(QString::number((terms[10])/(terms[9]-terms[11])));
this->answerline5->setText(QString::number((terms[13])/(terms[12]+terms[14])));
}
catch(const char * message)
{
cerr << "Error " << message << endl;
}

ChrisW67
15th August 2012, 23:36
Necessitas uses the Android NDK. Android NDK versions pre-NDK R5 do not support exceptions, and exceptions are off by default even in the later versions.

http://stackoverflow.com/questions/4663291/android-ndk-r5-and-support-of-c-exception
http://developer.android.com/tools/sdk/ndk/index.html#