I've seen this topic which describes the "stringify" operation by doing:
#define STR_HELPER(x) #x
#define STR(x) STR_HELPER(x)
#define MAJOR_VER 2
#define MINOR_VER 6
#define MY_FILE "/home/user/.myapp" STR(MAJOR_VER) STR(MINOR_VER)
Is it possible to stringify with leading zeros? Let's say my MAJOR_REV needs to be two characters "02" in this case and MINOR_REV 4 characters "0006" If I do:
#define MAJOR_VER 02
#define MINOR_VER 0006
The values will be treated as octal elsewhere in the application, which I don't want.
MAJOR_VER_STR
andMINOR_VER_STR
as strings with leading zeros. You could create a script to set major and minor version and the matching strings:setversion --major=2 --minor=7 header.h
which does the job. – Martinic#define MAJOR_VER (1)(0)
for major version 10. – Garemyapp
doesn't spam config files with every update? I cannot imagine the user will enjoy having to reconfiguremyapp
with every minor update... – Instrument