qt诡异的编译错误( forbids declaration of `parameter' with no type)
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了qt诡异的编译错误( forbids declaration of `parameter' with no type)相关的知识,希望对你有一定的参考价值。
代码:
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QList>
#include <QMainWindow>
class QAction;
class QMenu;
class QTextCodec;
class QTextEdit;
class PreviewForm;
class MainWindow : public QMainWindow
Q_OBJECT
public:
MainWindow();
public slots:
//LULU FONT
void slotFont(QString);
void slotSize(QString);
void slotBold();
void slotItalic();
void slotUnder();
void slotColor();
void slotPrint();
void slotCurrentFormatChanged(const QTextCharFormat &fmt);
void open();
void save();
void about();
void aboutToShowSaveAsMenu();
public:
void fontset();
void findCodecs();
void createActions();
void createMenus();
void createToolBars();
void mergeFormat(QTextCharFormat);
QTextEdit *textEdit;
PreviewForm *previewForm;
QList<QTextCodec *> codecs;
QMenu *fileMenu;
QMenu *helpMenu;
QMenu *saveAsMenu;
QAction *openAct;
QList<QAction *> saveAsActs;
QAction *exitAct;
QAction *aboutAct;
QAction *aboutQtAct;
QAction *fileSaveAction;
QAction *copyAction;
QAction *cutAction;
QAction *pasteAction;
QToolBar *fileTool;
QToolBar *editTool;
QLabel *label1;
QLabel *label2;
QFontComboBox *fontBox;
QComboBox *sizeBox;
QMenu *printMenu;
QAction *printAction;
QToolBar *printTool;
QToolButton *boldBtn;
QToolButton *italicBtn;
QToolButton *underBtn;
QToolButton *colorBtn;
;
#endif
下面是错误提示:
C:/Users/lulu/Desktop/programme/text/../mainwindow.h:31: error: expected `,' or `...' before '&' token
C:/Users/lulu/Desktop/programme/text/../mainwindow.h:31: error: ISO C++ forbids declaration of `QTextCharFormat' with no type
C:/Users/lulu/Desktop/programme/text/../mainwindow.h:43: error: `QTextCharFormat' has not been declared
C:/Users/lulu/Desktop/programme/text/../mainwindow.h:43: error: ISO C++ forbids declaration of `parameter' with no type
C:/Users/lulu/Desktop/programme/text/../mainwindow.h:61: error: ISO C++ forbids declaration of `QLabel' with no type
C:/Users/lulu/Desktop/programme/text/../mainwindow.h:61: error: expected `;' before '*' token
我明明声明了类型为什么还会提示没有声明?
处理:ISO C90 forbids mixed declarations and code 警告
编译的时候经常会遇到 ISO C90 forbids mixed declarations and code 警告
百度了一下,知道是如下原因 :
变量定义之前任何一条非变量定义的语句(注意:语句是会带分号的)都会引起这个警告!
解决方法:
将非变量的定义移到变量定义之后 即可
在内核中还需要将 printk的打印放在变量定义之后
(转载自:https://blog.csdn.net/android_huber/article/details/7371941)
以上是关于qt诡异的编译错误( forbids declaration of `parameter' with no type)的主要内容,如果未能解决你的问题,请参考以下文章
ISO C90 forbids mixed declarations and code 警告
处理:ISO C90 forbids mixed declarations and code 警告
Qt错误:QMessageBox: No such file or directory错误:'QsqlDatabase' has not been declared
解决QT:forward declaration of 'struct Ui::xxx';invalid use of incomplete struct &q
QT学习之forward declaration of 'struct Ui::xxx';invalid use of incomplete struct "Ui::Widg
arm linux c++编译警告:ISO C++ forbids converting a string constant to ‘char*’(需要把const char*转换成char*)(代码