I want to use the cross-platform function sleep. In one of the questions such a solution was proposed. Since qt has constants such as Q_OS_WIN32 and Q_OS_LINUX , I decided to use them rather than define some of my own.
The problem is that for some reason these constants are not seen (both blocks are gray), and if you set DEFINES += Q_OS_WIN32 in the .pro file, you DEFINES += Q_OS_WIN32 lot of errors about defining the override, i.e. once it is still determined, it just happens after the file is processed with the function.
I tried to include it as low as possible, but it does not help.
I tried to include at the very top of the main QtGlobal, since the constants are there, but it also did not help. How to solve this problem?

  • “I tried to turn in at the very top of the main QtGlobal” - this should solve the problem, it cannot be that it does not solve. - ixSci
  • @ixSci, ¯_ (ツ) _ / ¯ both blocks of code are gray, while compiling, the waring out of the unused variable sleepMs falls out, indicating that the function has an empty body. I do not know, maybe you need to take some other actions before assembling. - Andrey Solodovnikov
  • "I want to use the cross-platform function sleep" than the standard Qt function QThread::msleep() does not suit? If you use Qt, use its features to the maximum - Bearded Beaver

1 answer 1

As a result, the problem was solved by connecting the <QtGlobal> file directly to the header file with this function (and not to the very top of main, as described in the question).
I have no idea how this could affect, perhaps, in the process of optimizing the code, the order of defines was changed, but I would not risk saying this with confidence.