Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8823771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:26:30+00:00 2026-06-14T06:26:30+00:00

Version numbers are needed all over a project; in installers, code, toolchains etc. I

  • 0

Version numbers are needed all over a project; in installers, code, toolchains etc. I despise duplication. I want my version numbers to be stored in one central authoritative location.

I am working with C/C++ and using Qt on various platforms. In Qt, qmake projects specify version numbers like:

VERSION = 1.2.3

In code I use something like in a header like Version.h:

#define VERSION_MAJ 1
#define VERSION_MIN 2
#define VERSION_REV 3
#define VERSION_STRING \"VERSION_MAJ\" "." \"VERSION_MIN\" "." \"VERSION_REV\"

My installer toolchain has support for C preprocessing so I can use the same version specified in Version.h. However, I don’t know how to get qmake to use the same version number. I thought I could preprocess the pro file, but that won’t work as # characters mean a comment in pro files and the C preprocessor will fall over.

Anyone know of a good way to keep my version number centralised?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T06:26:31+00:00Added an answer on June 14, 2026 at 6:26 am

    If you want to be able to store your version numbers in a c header file, you can do so and then import them into the Qt project variables in the project file. Something like the below should work:

    Version.h:

    #define MY_MAJOR_VERSION 3
    #define MY_MINOR_VERSION 1
    

    .pro

    HEADERS  += Version.h
    
    VERSION_MAJOR = MY_MAJOR_VERSION
    VERSION_MINOR = MY_MINOR_VERSION
    

    The advantage of doing it this way round is that you can then use your authoritative header file if you need to compile other parts of the project away from Qt.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to write a cmp -like function that compares two version numbers and
So Product Management have decreed that our software should have version numbers with 3
I'm struggling with checking the validity of version numbers in Perl. Correct version number
I'm somewhat confused on the Linux kernel version numbers. I noticed that many Linux
It's easy to set the build and version numbers manually in Xcode, and I
Short version: What's the best practice going forward for efficiently rendering large numbers of
I've been working on a (nearly finished) Javascript project for a little over 14
I wrote a build script in ant. The source code of my project is
I run an open source project that normally distributes our code in a universal
My project is made of 5 sub projects. One is a War, and the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.