Menu

No Constructor message

2018-12-20
2019-01-03
  • Bob Stafford

    Bob Stafford - 2018-12-20

    I'm getting a lot of messages like this

    [/home/bobstaff/NoConstructor.cpp:32]: (style) The class 'EmailAlertActionPlugin' does not have a constructor although it has private member variables.

    I'm get this with 1.86 and HEAD. I'm running cppcheck as follows

    ~/cppcheck/cppcheck --inline-suppr --library=qt.cfg --enable=warning,style,performance,portability --platform=unix64 ~/NoConstructor.cpp

    Here is a code snippet that demonstrates the problem

    namespace Edge
    {

    class EmailAlertActionPlugin: public QObject, public Edge::AlertActionInterface, public EdgeInterface
    {
    
    public:
        explicit EmailAlertActionPlugin(QObject *parent = 0);
        ~EmailAlertActionPlugin() override;
    
    private:
        SmtpSender *m_smtpSender;
        QList<Smtp> m_emailList;
    };
    

    }

     
  • versat

    versat - 2018-12-21

    Hmm, i can not reproduce it with this code snippet. Not with 1.86 and not with HEAD.
    Have you tested it with this snippet or is it just a reduced example to show some code where it could happen?

     
  • Bob Stafford

    Bob Stafford - 2018-12-21

    Very sorry I posted the wrong snippet I tested quite a few . The QPLUGIN_METADATA line seems to be important.

    namespace Edge
    {
    
        class EmailAlertActionPlugin: public QObject, public Edge::AlertActionInterface, public EdgeInterface
        {
    
            Q_OBJECT
            Q_PLUGIN_METADATA(IID "com.eecweathertech.edge.window.emailalertaction" FILE "plugin.json")
    
        public:
            explicit EmailAlertActionPlugin(QObject *parent = 0);
            ~EmailAlertActionPlugin() override;
    
        private:
            SmtpSender *m_smtpSender;
            QList<Smtp> m_emailList;
        };
    
    }
    
     
  • Bob Stafford

    Bob Stafford - 2018-12-21

    Adding this line to qt.cfg seems to fix the problem

    <define name="Q_PLUGIN_METADATA(x)" value=""></define>

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.