[Qt-interest] application version and DRY principle

Harri Pasanen grego at mpaja.com
Fri Feb 18 14:49:59 CET 2011


See

http://en.wikipedia.org/wiki/C_preprocessor#Quoting_macro_arguments

Friday, February 18, 2011 01:18 pm 
Dmitry Teslenko writes:
> On Fri, Feb 18, 2011 at 14:50, Konrad Rosenbaum <konrad at silmor.de> wrote:
> > On Fri, February 18, 2011 12:20, Dmitry Teslenko wrote:
> >> How to define application version once and use it everywhere:
> >> a) in *.pro file to set custom package name like Program-<version>
> > 
> > Have a look at the DEFINES variable of qmake (there is quite an extensive
> > reference for qmake in the Qt docu).
> > 
> >> b) in c++ sources to pass it to QApplication::setVersionNumber and
> >> have about dialog with version number
> > 
> > DEFINES get passed to the compiler, so you can put any kind of macro
> > inside, for example
> > 
> > DEFINES += MYAPPVERSION="1.2.3 beta build 234"
> 
> Did you use it for yourself or you just heard of defines?
> 
> The way you suggest it me I'll get this makefile:
> 
> DEFINES = -DMYAPPVERSION=1.2.3 beta build 234 -DSOMETHING_ELSE
> 
> That's unusable makefile.
> If you add additional quotes like this:
> 
> DEFINES += MYAPPVERSION="\"1.2.3 beta build 234\""
> 
> You'll get right makefile. But you'll get  syntax error in source code
> because when you type something like this:
> 
> QApplication::setApplicationVersion(MYAPPVERSION);
> 
> Compliler will get:
> 
> QApplication::setApplicationVersion(1.2.3 beta build 234);
> 
> and will complain. And he would be right.
> 
> > You probably meant QCoreApplication::setApplicationVersion(QString) -
> > right?
> 
> Yes, you are right. Thanks.

Harri
http://mpaja.com/



More information about the Qt-interest-old mailing list