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. Running different piece of code on different platforms like linux ,windows and android
Forum Updated to NodeBB v4.3 + New Features

Running different piece of code on different platforms like linux ,windows and android

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 785 Views 1 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.
  • D Offline
    D Offline
    divaindie
    wrote on last edited by
    #1

    Hi all,
    i want to execute a particular piece of code only on windows and some piece of code only on linux(similarly for android ).now my question is is there any macro flags are there to achieve this (or any other method is there also fine)
    i want to execute code as below example
    Ex : #ifdef linux_Os_platform
    code_1
    #ifdef windows_os_platform
    code_2
    #ifdef android_os_platform
    code_3

    thanks !!

    J.HilkJ 1 Reply Last reply
    0
    • D divaindie

      Hi all,
      i want to execute a particular piece of code only on windows and some piece of code only on linux(similarly for android ).now my question is is there any macro flags are there to achieve this (or any other method is there also fine)
      i want to execute code as below example
      Ex : #ifdef linux_Os_platform
      code_1
      #ifdef windows_os_platform
      code_2
      #ifdef android_os_platform
      code_3

      thanks !!

      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      @divaindie

      sure is

      #if defined(Q_OS_IOS)
          //Ios
      #elif defined(Q_OS_MACOS)
          //Macos
      #elif defined(Q_OS_WIN)
          //Windows
      #elif defined(Q_OS_ANDROID)
          //Android
      #else
      .....
      #endif
      

      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      1 Reply Last reply
      2
      • D Offline
        D Offline
        divaindie
        wrote on last edited by
        #3

        @J.Hilk said in Running different piece of code on different platforms like linux ,windows and android:

        #if defined(Q_OS_IOS)

        for linux any flags exists ??

        J.HilkJ 1 Reply Last reply
        0
        • D divaindie

          @J.Hilk said in Running different piece of code on different platforms like linux ,windows and android:

          #if defined(Q_OS_IOS)

          for linux any flags exists ??

          J.HilkJ Offline
          J.HilkJ Offline
          J.Hilk
          Moderators
          wrote on last edited by
          #4

          @divaindie

          here, a more refined article than a quick copy&past from my current project :-)

          https://wiki.qt.io/Get_OS_name


          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          1 Reply Last reply
          4
          • D Offline
            D Offline
            divaindie
            wrote on last edited by
            #5

            @J-Hilk thanks!!! it solved my issue.

            mrjjM 1 Reply Last reply
            0
            • D divaindie

              @J-Hilk thanks!!! it solved my issue.

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @divaindie
              Super please set as Solved :)

              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