Johan 't Hart wrote:
Hi,
I don't know if boost has a solution for my problem, or there is just something simple I miss... I've been struggling with some preprocessor things. I'm trying to use it for versioning. Here is the problem:
I've got these defines:
#define VERSION_MAJOR 5 #define VERSION_MINOR 4 #define VERSION_BUILD 3 #define VERSION_SUBBUILD 2
Sometimes I just need a string like: "5.4.3.2". I do it like this:
#define STRINGER_(s) #s #define STRINGER(s) STRINGER_(s) #define VERSION_STRING_1 \ STRINGER(VERSION_MAJOR) "." \ STRINGER(VERSION_MINOR) "." \ STRINGER(VERSION_BUILD) "." \ STRINGER(VERSION_SUBBUILD)
So VERSION_STRING_1 is "5.4.3.2" Now I need a string like: "5.4.3b". (Note the 'b'. When VERSION_SUBBUILD == 3, I want it to be a 'c' etc) How do I do this in a preprocessor command???? The char is simple, its (VERSION_SUBBUILD+'a'-1).
You need a lookup table to do it all in the preprocessor, AFAIK:
#include