diff --git a/include/version.h b/include/version.h index 15a9de15..8359f239 100644 --- a/include/version.h +++ b/include/version.h @@ -9,9 +9,9 @@ #ifndef EXTERN_VERSION_H #define EXTERN_VERSION_H -#define PACKAGE_VERSION_MAJOR (0) -#define PACKAGE_VERSION_MINOR (4) -#define PACKAGE_VERSION_PATCH (2) +#define PACKAGE_VERSION_MAJOR 0 +#define PACKAGE_VERSION_MINOR 4 +#define PACKAGE_VERSION_PATCH 2 const char *get_package_version_string(void); diff --git a/src/version.c b/src/version.c index 77868e99..0f716e01 100644 --- a/src/version.c +++ b/src/version.c @@ -9,17 +9,17 @@ #include #include +#include "helpers.h" #include "version.h" const char *get_package_version_string(void) { - static char s[50]; - - /* The following conditional should be simplified by the compiler. */ + // The following conditional should be simplified by the compiler. if (strlen(BUILD_VERSION_STRING) == 0) { - snprintf(s, sizeof(s), "v%d.%d.%d", PACKAGE_VERSION_MAJOR, - PACKAGE_VERSION_MINOR, PACKAGE_VERSION_PATCH); - return s; + // Fallback if version string can't be obtained from Git + return "v" EXPAND_AND_STR(PACKAGE_VERSION_MAJOR) + "." EXPAND_AND_STR(PACKAGE_VERSION_MINOR) + "." EXPAND_AND_STR(PACKAGE_VERSION_PATCH); } else { return BUILD_VERSION_STRING; }