Thread: Automatic build number on about page

  1. #1
    Registered User
    Join Date
    Nov 2007
    Posts
    14

    Automatic build number on about page

    Hi guys,

    i have a already finish application in which i use an about dialog frame to show the application version. I also would like to show the build number for better versioning.

    Is there any way to have the build number automatically generated and put out?
    I'm working with gcc.

    Thanks a lot in advance

    rat

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Create a little script/program that generates something along the lines of:
    Code:
    #define BUILDNUMBER 1
    The script should generate "the next number" each time you compile.

    Make this part of the makefile or whatever you use to build the project.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Nov 2007
    Posts
    14
    ok sounds good but how do i count every build process?

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Assuming you use a "makefile", just add it as part of the "recipe" for the final build. Something like:

    Code:
    all: myprog
        updatebuildnumber
    
    myprog: myprog.o somefile.o other.o
        gcc -o $@ $<
    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  5. #5
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    bloodshed dev/c++ does automatic versioning without that hacky method

    you have to go into the project settings and turn on automatic versioning, after that its some #define'd variable, i forget which, but a google search should tell you.

  6. #6
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by abachler View Post
    bloodshed dev/c++ does automatic versioning without that hacky method

    you have to go into the project settings and turn on automatic versioning, after that its some #define'd variable, i forget which, but a google search should tell you.
    Good idea.

    However, what you mean is that some part of the IDE is creating a automatic build/version number for you - it's just as "hacky" except it's someone else's hack, right? And of course, it relies on using that particular IDE, which may or may not be what the original poster does.

    A long time ago, I used to have a little program that would find a string like "V1.0-00A" in a specified file and update it to "V1.0-00B" and so on. It was part of my "custom processing at end of build".

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  7. #7
    Registered User
    Join Date
    Nov 2007
    Posts
    14
    is there no gcc define that counts the number of builds of that file?

    would be the easiest to output like BUILDNR...

  8. #8
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by abachler View Post
    bloodshed dev/c++ does automatic versioning without that hacky method
    There's nothing hacky about it.

  9. #9
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by ratte View Post
    is there no gcc define that counts the number of builds of that file?

    would be the easiest to output like BUILDNR...
    gcc has no idea how many times you have compiled the project. An IDE could have the ability to do this, assuming you always use the IDE [or the IDE's method] to build the project.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  10. #10
    Registered User
    Join Date
    Nov 2007
    Posts
    14
    I'll have a look if there's something (maybe plugin) provided in code::blocks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Program giving errors
    By andy bee in forum C Programming
    Replies: 5
    Last Post: 08-11-2010, 10:38 PM
  2. adding a number to a number
    By bigmac(rexdale) in forum C Programming
    Replies: 11
    Last Post: 10-24-2007, 12:56 PM
  3. scanf oddities
    By robwhit in forum C Programming
    Replies: 5
    Last Post: 09-22-2007, 01:03 AM
  4. Boom, Headoshot!!
    By mrafcho001 in forum A Brief History of Cprogramming.com
    Replies: 50
    Last Post: 07-21-2005, 08:28 PM
  5. help with a source code..
    By venom424 in forum C++ Programming
    Replies: 8
    Last Post: 05-21-2004, 12:42 PM