Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved Static inline QReadWriteLock class member

    General and Desktop
    1
    1
    84
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • C
      Cocojambo last edited by

      // 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;
            |                                      ^~~~~~
      
      1 Reply Last reply Reply Quote 0
      • First post
        Last post