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. QMAKE DEFINES in Application
Forum Updated to NodeBB v4.3 + New Features

QMAKE DEFINES in Application

Scheduled Pinned Locked Moved Solved General and Desktop
qmakedefines
5 Posts 2 Posters 2.5k 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.
  • L Offline
    L Offline
    lolopolosko
    wrote on last edited by
    #1

    Hello, Everyone

    I`m try use QMAKE DEFINES in cpp source.
    I put this values into my .pro file

    VERSION = 1.0.1.2
    DEFINES += VERSION=\\\"$$VERSION\\\"
    

    And read in cpp source

    QString version(VERSION);
    qDebug() << "Version" << version;
    

    But when I compile with MSVC 2013 I have this error

    ****\main.cpp:8: error: C2065: 'VERSION' : undeclared identifier
    

    How I can read DEFINE from *.pro file?

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by A Former User
      #2

      Hi! MSVC and gcc use different syntax for constants on the command line. The following should work (can't test it right now):

      VERSION = 1.0.1.2
      unix:DEFINES += VERSION=\\\"$$VERSION\\\"
      win32:DEFINES += VERSION=\"$$VERSION\"
      

      EDIT: There have to be DOUBLE DOLLAR SIGNS. The forum software won't let me type this correctly. :-/

      1 Reply Last reply
      1
      • L Offline
        L Offline
        lolopolosko
        wrote on last edited by lolopolosko
        #3

        Ok,
        I test it. And...... It isnt work

        I`m change

        VERSION = 1.0.1.2
        DEFINES += VERSION=\\\"$$VERSION\\\"
        

        to

        unix:DEFINES += VERSION=\\\"$$VERSION\\\"
        win32:DEFINES += VERSION=\"$$VERSION\"
        

        And I have error:

        ****\main.cpp:8: error: C2065: 'VERSION' : undeclared identifier
        
        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

          Really? Just to be sure: Please clean your project and rebuild it.

          1 Reply Last reply
          0
          • L Offline
            L Offline
            lolopolosko
            wrote on last edited by lolopolosko
            #5

            Clean project
            And have new error

            ****\main.cpp:8: error: C2143: syntax error : missing ')' before 'constant'
            ****\main.cpp:8: error: C2664: 'QString::QString(QStringDataPtr)' : cannot convert argument 1 from 'double' to 'const QChar *'
            ****\main.cpp:8: error: C2059: syntax error : ')'
            

            EDIT:
            Now I add new macro

            #define _TOSTR(x) #x
            #define TOSTR(X) _TOSTR(X)
            

            And now I can use DEFINES from *.pro file

            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