I want to pass a version string in the compile command:
$ g++ -Wall -D VERSION=\"2013-12-03 02:15:21, commit cb060df\" -o
__VA_ARGS__ must be in each call:
#define _STRINGIZE(...) #__VA_ARGS__
#define STRINGIZE(...) _STRINGIZE(__VA_ARGS__)
You can write the TOSTR_
macro to take variable arguments:
#define TOSTR_(x...) #x
#define STRINGIFY(x) TOSTR_(x)
#define VERSION_STR STRINGIFY(VERSION)
This code has been tested and works on Apple LLVM version 5.0.