How can one include a struct
defined in an external header file into another file? At first, I passed the struct by pointer, so I only needed a forward declaration. But now I want to pass by value and can't make it compile. The header lagerverwaltung.h
does include the struct, so where is the problem?
file lagerverwaltung.h
:
#ifndef LAGERVERWALTUNG_H
#define LAGERVERWALTUNG_H
struct etikettInfo{
QString userName;
QList<struct properties_content *> inhalte;
};
class Lagerverwaltung : public QMainWindow
{
Q_OBJECT
... and so on
};
#endif // LAGERVERWALTUNG_H
file etikett1.h
:
#ifndef ETIKETT1_H
#define ETIKETT1_H
#include "lagerverwaltung.h" // for struct etikettInfo
class Lagerverwaltung;
//struct etikettInfo;
namespace Ui {
class Etikett1;
}
class Etikett1 : public QMainWindow
{
Q_OBJECT
public:
explicit Etikett1(Lagerverwaltung *mainwindow,
etikettInfo etikettData, // <- struct etikettInfo has not been declared
QWidget* parent = 0);
~Etikett1();
private:
Ui::Etikett1 *ui;
Lagerverwaltung *lgrvw;
etikettInfo etikettData; // <- struct etikettInfo does not name a type
};
#endif // ETIKETT1_H
If it matters: Both .h-files do have include guards.
Ok the error messages (see comments in code) are really quite descriptive but I don't know what I should do differently.
As it stands the
needs the proper includes for this to be a properly declared struct. So add
as well as declaration for
properties_content
.