what does this mean " error: ISO C++ forbids declaration of --- with no type?
HI
i am getting this error "error: ISO C++ forbids declaration of ‘-----’ with no type"
when do we get this error ??
Thnkx in advance...
Re: what does this mean " error: ISO C++ forbids declaration of --- with no type?
Re: what does this mean " error: ISO C++ forbids declaration of --- with no type?
Most likely you forgot a necessary forward declaration or include.
Re: what does this mean " error: ISO C++ forbids declaration of --- with no type?
@fatjuicymole
mainwindow.h file.. i am getting the error in this code.
Code:
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QThread>
#include <QMessageBox>
#include <QtGui/QMainWindow>
#include "sampleThread.h"
namespace Ui
{
class MainWindow;
}
{
Q_OBJECT
public:
~MainWindow();
private:
Ui::MainWindow *ui;
sampleThread *newThread;//in this line
};
#endif // MAINWINDOW_H
Re: what does this mean " error: ISO C++ forbids declaration of --- with no type?
What is the contents of sampleThread.h?
Re: what does this mean " error: ISO C++ forbids declaration of --- with no type?
Code:
#ifndef SAMPLETHREAD_H
#define SAMPLETHREAD_H
#include <QMessageBox>
#include <QThread>
#include "mainwindow.h"
{
public:
sampleThread();
void run();
};
#endif // SAMPLETHREAD_H
Re: what does this mean " error: ISO C++ forbids declaration of --- with no type?
actually it is sampleThread only
Re: what does this mean " error: ISO C++ forbids declaration of --- with no type?
Quote:
Originally Posted by
qtlinuxnewbie
actually it is sampleThread only
??? Pardon? I don't understand.
It is either:
QThread *newThread;
or:
sampleThread *newThread;
You don't have a class 'Thread'.
Re: what does this mean " error: ISO C++ forbids declaration of --- with no type?
may be i was not clear for u .
it is
Code:
sampleThread *newThread
Re: what does this mean " error: ISO C++ forbids declaration of --- with no type?
In the code you have posted, you use just "Thread", not "sampleThread".
Re: what does this mean " error: ISO C++ forbids declaration of --- with no type?
i changed the posted code to sampleThread and tried to build but i am getting the same error.
Re: what does this mean " error: ISO C++ forbids declaration of --- with no type?
You have a loop in your includes - mainwindow.h includes sampleThread.h which again includes mainwindow.h. Use a forward declaration in mainwindow.h instead of including sampleThread.h or don't include mainwindow.h in the other file.