Nik*_*ita 4 c++ qt compiler-errors include header-files
在它们的头中有两个相互关联的类:
绘图标记
#ifndef PLOTMARKER_H
#define PLOTMARKER_H
#include <QObject>
#include "plotter.h"
class Plotter;
class PlotMarker : public QObject
{
// ...
Plotter* m_attachedPlot;
// ...
};
#endif // PLOTMARKER_H
Run Code Online (Sandbox Code Playgroud)
绘图仪
#ifndef PLOTTER_H
#define PLOTTER_H
// ...
#include "plotmarker.h"
// ...
class PlotMarker;
class Plotter : public QQuickPaintedItem
{
// ...
QLinkedList<PlotMarker*> m_markerList;
// ...
};
#endif // PLOTTER_H
Run Code Online (Sandbox Code Playgroud)
程序编译良好,但出现错误error: unterminated conditional directive,#ifndefIDE 中的类代码因此没有突出显示。
如果我#include "plotter.h"在 PlotMarker 的标头或#include "plotmarker.h"Plotter 的标头中删除,Qt Creator 会像往常一样突出显示代码,但由于有关无效使用不完整类型的错误,编译失败。
你能告诉我有什么问题吗?我认为这是因为错误的标题交叉引用,但我遇到了这个并且没有帮助我。
问题已经解决了。
我只是将其中一个#include从头文件移到源文件中,它已经奏效了。
绘图标记.h
#ifndef PLOTMARKER_H
#define PLOTMARKER_H
#include <QObject>
class Plotter;
class PlotMarker : public QObject
{
// ...
Plotter* m_attachedPlot;
// ...
};
#endif // PLOTMARKER_H
Run Code Online (Sandbox Code Playgroud)
// ...
绘图标记.cpp
#include "plotmarker.h"
#include "plotter.h"
// ...
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
25804 次 |
| 最近记录: |