diff options
author | lloyd <[email protected]> | 2012-09-14 17:22:16 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2012-09-14 17:22:16 +0000 |
commit | 85919e894b8880bee5274a6c9f5c895218351d52 (patch) | |
tree | 955bab4d405840247b954a8c95475b799eb501de /src/utils/version.cpp | |
parent | 21d74f1ab41aef6cf5342a4f4ba34e434ff4727a (diff) |
Build the return value of version_string at compile time instead of at
runtime so it's easy to find in a binary with strings.
Diffstat (limited to 'src/utils/version.cpp')
-rw-r--r-- | src/utils/version.cpp | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/src/utils/version.cpp b/src/utils/version.cpp index acc8bee61..49fec4392 100644 --- a/src/utils/version.cpp +++ b/src/utils/version.cpp @@ -7,7 +7,6 @@ #include <botan/version.h> #include <botan/parsing.h> -#include <sstream> namespace Botan { @@ -22,21 +21,23 @@ namespace Botan { */ std::string version_string() { - std::ostringstream out; - - out << "Botan " << version_major() << "." - << version_minor() << "." - << version_patch() << " ("; - - if(BOTAN_VERSION_DATESTAMP == 0) - out << "unreleased version"; - else - out << "released " << version_datestamp(); - - out << ", revision " << BOTAN_VERSION_VC_REVISION; - out << ", distribution " << BOTAN_DISTRIBUTION_INFO << ")"; - - return out.str(); +#define QUOTE(name) #name +#define STR(macro) QUOTE(macro) + + return "Botan " STR(BOTAN_VERSION_MAJOR) "." + STR(BOTAN_VERSION_MINOR) "." + STR(BOTAN_VERSION_PATCH) " (" + +#if (BOTAN_VERSION_DATESTAMP == 0) + "unreleased version built " __DATE__ +#else + "released " STR(BOTAN_VERSION_DATESTAMP) +#endif + ", revision " BOTAN_VERSION_VC_REVISION + ", distribution " BOTAN_DISTRIBUTION_INFO ")"; + +#undef STR +#undef QUOTE } u32bit version_datestamp() { return BOTAN_VERSION_DATESTAMP; } |