I would like to know if there is a way to embed Mercurial tags into my C/C++ code.
Basically I would like the tag string, which will end up being a release number (
We use a macro for this
#define CVS(a) static const volatile char *rcsid = a;
....
CVS("$Id$")
CVS automagically expands $Id$. I assume this is what mercurial tags work as well.
Then we can use the strings command to find the exact version of each file in the executable / library etc.
You could use something similar.
static const volatile char *rcsid = "$Id"; //or whatever mercurial tag you want
int main() {
.....
std::cout << "Version is " << rcsid << std::endl;
}