Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for WebAssembly
  4. Test if WebAssembly in C++ code
Forum Updated to NodeBB v4.3 + New Features

Test if WebAssembly in C++ code

Scheduled Pinned Locked Moved Solved Qt for WebAssembly
4 Posts 3 Posters 1.0k 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.
  • M Offline
    M Offline
    Mixlu
    wrote on 7 May 2020, 13:03 last edited by Mixlu 5 Jul 2020, 13:05
    #1

    Hi,
    I have an application on Qt 5.13.2, I use MinGW (windows) for development and then I compile it in WebAssembly.
    I would like to call different C++ function depending on the compiler (mingw/webassembly), is there a way to do it in C++ files ?

    I have seen this but this is for the .pro file :

    contains(CONFIG, mingw) {
        
    } else {
        contains(CONFIG, wasm) {
           
        }
    }
    
    J 1 Reply Last reply 7 May 2020, 13:10
    1
    • M Mixlu
      7 May 2020, 13:03

      Hi,
      I have an application on Qt 5.13.2, I use MinGW (windows) for development and then I compile it in WebAssembly.
      I would like to call different C++ function depending on the compiler (mingw/webassembly), is there a way to do it in C++ files ?

      I have seen this but this is for the .pro file :

      contains(CONFIG, mingw) {
          
      } else {
          contains(CONFIG, wasm) {
             
          }
      }
      
      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 7 May 2020, 13:10 last edited by jsulm 5 Jul 2020, 13:11
      #2

      @Mixlu Such things are done via

      #ifdef SOMETHING
      // Do something
      #endif
      

      in C++ (https://en.cppreference.com/w/cpp/preprocessor/conditional).

      Such defines can be added using https://doc.qt.io/qt-5/qmake-variable-reference.html#defines in qmake:

      DEFINES += SOMETHING
      

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      M 1 Reply Last reply 7 May 2020, 13:14
      3
      • J jsulm
        7 May 2020, 13:10

        @Mixlu Such things are done via

        #ifdef SOMETHING
        // Do something
        #endif
        

        in C++ (https://en.cppreference.com/w/cpp/preprocessor/conditional).

        Such defines can be added using https://doc.qt.io/qt-5/qmake-variable-reference.html#defines in qmake:

        DEFINES += SOMETHING
        
        M Offline
        M Offline
        Mixlu
        wrote on 7 May 2020, 13:14 last edited by
        #3

        @jsulm

        Thanks, this is what I was looking for!

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 7 May 2020, 13:32 last edited by
          #4

          Hi,

          Even simpler use Qt's OS defines: Q_OS_WASM:

          #ifdef Q_OS_WASM
          // You WASM specific code
          #endif
          

          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
          6

          1/4

          7 May 2020, 13:03

          • Login

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