Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Static inline QReadWriteLock class member



  • // classname.h
    #pragma once
    #include <QReadWriteLock>
    #include <QString>
    
    class ClassName {
        public:
           /*inline*/ static QReadWriteLock locker;
           inline static QString string;
    };
    
    // classname.cpp
    //QReadWriteLock ClassName::locker;
    

    Could you explain why inline static declaration doesn't work here? But it works when inline keyword is uncommented and the line in classname.cpp is too. For inline static string member it works correctly.

    /another_test/classname.h:6: error: no matching function for call to ‘QReadWriteLock::QReadWriteLock()’
    In file included from ../another_test/classname.cpp:1:
    ../another_test/classname.h:6:38: error: no matching function for call to ‘QReadWriteLock::QReadWriteLock()’
        6 |         inline static QReadWriteLock locker;
          |                                      ^~~~~~
    

Log in to reply