From f0b777207eb8ba9f0453c1af9a57f1426fb7fc74 Mon Sep 17 00:00:00 2001 From: Martchus Date: Tue, 8 May 2018 00:35:35 +0200 Subject: [PATCH] Fix dependency version under GCC 8 --- application/argumentparser.cpp | 11 ++++++++--- application/argumentparser.h | 5 +++-- tests/argumentparsertests.cpp | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/application/argumentparser.cpp b/application/argumentparser.cpp index 4d8cd06..c5a6ef7 100644 --- a/application/argumentparser.cpp +++ b/application/argumentparser.cpp @@ -407,7 +407,12 @@ const char *applicationVersion = nullptr; /// \brief Specifies the URL to the application website (used by ArgumentParser::printHelp()). const char *applicationUrl = nullptr; /// \brief Specifies the dependency versions the application was linked against (used by ArgumentParser::printHelp()). +/// \deprecated Not used anymore. Use dependencyVersions2 instead. std::initializer_list dependencyVersions; +/// \brief Specifies the dependency versions the application was linked against (used by ArgumentParser::printHelp()). +std::vector dependencyVersions2; + +// TODO v5 use a struct for these properties /*! * \brief Specifies a function quit the application. @@ -772,18 +777,18 @@ void ArgumentParser::printHelp(ostream &os) const if (applicationVersion && *applicationVersion) { os << "version " << applicationVersion; } - if (dependencyVersions.size()) { + if (dependencyVersions2.size()) { if ((applicationName && *applicationName) || (applicationVersion && *applicationVersion)) { os << '\n'; EscapeCodes::setStyle(os); } - auto i = dependencyVersions.begin(), end = dependencyVersions.end(); + auto i = dependencyVersions2.begin(), end = dependencyVersions2.end(); os << "Linked against: " << *i; for (++i; i != end; ++i) { os << ',' << ' ' << *i; } } - if ((applicationName && *applicationName) || (applicationVersion && *applicationVersion) || dependencyVersions.size()) { + if ((applicationName && *applicationName) || (applicationVersion && *applicationVersion) || dependencyVersions2.size()) { os << '\n' << '\n'; } EscapeCodes::setStyle(os); diff --git a/application/argumentparser.h b/application/argumentparser.h index fcb4536..357f68e 100644 --- a/application/argumentparser.h +++ b/application/argumentparser.h @@ -22,6 +22,7 @@ CPP_UTILITIES_EXPORT extern const char *applicationAuthor; CPP_UTILITIES_EXPORT extern const char *applicationVersion; CPP_UTILITIES_EXPORT extern const char *applicationUrl; CPP_UTILITIES_EXPORT extern std::initializer_list dependencyVersions; +CPP_UTILITIES_EXPORT extern std::vector dependencyVersions2; /*! * \def SET_DEPENDENCY_INFO @@ -30,9 +31,9 @@ CPP_UTILITIES_EXPORT extern std::initializer_list dependencyVersio * \remarks Reads those data from the config header so "config.h" must be included. */ #ifndef APP_STATICALLY_LINKED -#define SET_DEPENDENCY_INFO ::ApplicationUtilities::dependencyVersions = DEPENCENCY_VERSIONS +#define SET_DEPENDENCY_INFO ::ApplicationUtilities::dependencyVersions2 = DEPENCENCY_VERSIONS #else -#define SET_DEPENDENCY_INFO ::ApplicationUtilities::dependencyVersions = STATIC_DEPENCENCY_VERSIONS +#define SET_DEPENDENCY_INFO ::ApplicationUtilities::dependencyVersions2 = STATIC_DEPENCENCY_VERSIONS #endif /*! diff --git a/tests/argumentparsertests.cpp b/tests/argumentparsertests.cpp index e0e50bc..7da48dc 100644 --- a/tests/argumentparsertests.cpp +++ b/tests/argumentparsertests.cpp @@ -731,7 +731,7 @@ void ArgumentParserTests::testHelp() parser.addMainArgument(&verboseArg); parser.addMainArgument(&filesArg); parser.addMainArgument(&envArg); - dependencyVersions = { "somelib", "some other lib" }; + dependencyVersions2 = { "somelib", "some other lib" }; // parse args and assert output const char *const argv[] = { "app", "-h" };