Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Why would #ifdef Q_OS_DARWIN not work on a Mac?
Forum Updated to NodeBB v4.3 + New Features

Why would #ifdef Q_OS_DARWIN not work on a Mac?

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 2 Posters 1.3k Views 2 Watching
  • 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.
  • StokestackS Offline
    StokestackS Offline
    Stokestack
    wrote on last edited by
    #1

    Hi all.

    If I enclose code with this on a Mac, it's marked as disabled and indeed is not compiled.

    Anyone know why?

    Thanks!

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      It's all in the doc of Q_OS_DARWIN.

      For more information about why Darwin, see here.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • StokestackS Offline
        StokestackS Offline
        Stokestack
        wrote on last edited by Stokestack
        #3

        Thanks for your reply. I had read that doc, but it simply says the symbol IS defined.

        The preprocessor, despite being on a Mac, says it ISN'T defined. It also says Q_OS_MACOS isn't defined.

        UPDATE: I discovered what triggers the failure: If #ifdef is the first significant line in the file, it doesn't work. If you have something else above it (like a #include), it works. I've never encountered this before. Is it normal?

        0_1549233401883_ifdef.png

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Yes it's normal, Q_OS_DARWIN is not defined by the compiler, you can find it the QtGlobals header. As long as you don't include anything Qt, you won't have access to any of these platform defines.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          1
          • StokestackS Offline
            StokestackS Offline
            Stokestack
            wrote on last edited by
            #5

            Good to know. Thanks.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              You're welcome !

              If you have all the answers you need, please mark the thread as solved using the "Topic Tools" button so that other forum users may know it's good :)

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved