Fix dependency version under GCC 8

This commit is contained in:
Martchus 2018-05-08 00:35:35 +02:00
parent a4435bbcf3
commit f0b777207e
3 changed files with 12 additions and 6 deletions

View File

@ -407,7 +407,12 @@ const char *applicationVersion = nullptr;
/// \brief Specifies the URL to the application website (used by ArgumentParser::printHelp()). /// \brief Specifies the URL to the application website (used by ArgumentParser::printHelp()).
const char *applicationUrl = nullptr; const char *applicationUrl = nullptr;
/// \brief Specifies the dependency versions the application was linked against (used by ArgumentParser::printHelp()). /// \brief Specifies the dependency versions the application was linked against (used by ArgumentParser::printHelp()).
/// \deprecated Not used anymore. Use dependencyVersions2 instead.
std::initializer_list<const char *> dependencyVersions; std::initializer_list<const char *> dependencyVersions;
/// \brief Specifies the dependency versions the application was linked against (used by ArgumentParser::printHelp()).
std::vector<const char *> dependencyVersions2;
// TODO v5 use a struct for these properties
/*! /*!
* \brief Specifies a function quit the application. * \brief Specifies a function quit the application.
@ -772,18 +777,18 @@ void ArgumentParser::printHelp(ostream &os) const
if (applicationVersion && *applicationVersion) { if (applicationVersion && *applicationVersion) {
os << "version " << applicationVersion; os << "version " << applicationVersion;
} }
if (dependencyVersions.size()) { if (dependencyVersions2.size()) {
if ((applicationName && *applicationName) || (applicationVersion && *applicationVersion)) { if ((applicationName && *applicationName) || (applicationVersion && *applicationVersion)) {
os << '\n'; os << '\n';
EscapeCodes::setStyle(os); EscapeCodes::setStyle(os);
} }
auto i = dependencyVersions.begin(), end = dependencyVersions.end(); auto i = dependencyVersions2.begin(), end = dependencyVersions2.end();
os << "Linked against: " << *i; os << "Linked against: " << *i;
for (++i; i != end; ++i) { for (++i; i != end; ++i) {
os << ',' << ' ' << *i; os << ',' << ' ' << *i;
} }
} }
if ((applicationName && *applicationName) || (applicationVersion && *applicationVersion) || dependencyVersions.size()) { if ((applicationName && *applicationName) || (applicationVersion && *applicationVersion) || dependencyVersions2.size()) {
os << '\n' << '\n'; os << '\n' << '\n';
} }
EscapeCodes::setStyle(os); EscapeCodes::setStyle(os);

View File

@ -22,6 +22,7 @@ CPP_UTILITIES_EXPORT extern const char *applicationAuthor;
CPP_UTILITIES_EXPORT extern const char *applicationVersion; CPP_UTILITIES_EXPORT extern const char *applicationVersion;
CPP_UTILITIES_EXPORT extern const char *applicationUrl; CPP_UTILITIES_EXPORT extern const char *applicationUrl;
CPP_UTILITIES_EXPORT extern std::initializer_list<const char *> dependencyVersions; CPP_UTILITIES_EXPORT extern std::initializer_list<const char *> dependencyVersions;
CPP_UTILITIES_EXPORT extern std::vector<const char *> dependencyVersions2;
/*! /*!
* \def SET_DEPENDENCY_INFO * \def SET_DEPENDENCY_INFO
@ -30,9 +31,9 @@ CPP_UTILITIES_EXPORT extern std::initializer_list<const char *> dependencyVersio
* \remarks Reads those data from the config header so "config.h" must be included. * \remarks Reads those data from the config header so "config.h" must be included.
*/ */
#ifndef APP_STATICALLY_LINKED #ifndef APP_STATICALLY_LINKED
#define SET_DEPENDENCY_INFO ::ApplicationUtilities::dependencyVersions = DEPENCENCY_VERSIONS #define SET_DEPENDENCY_INFO ::ApplicationUtilities::dependencyVersions2 = DEPENCENCY_VERSIONS
#else #else
#define SET_DEPENDENCY_INFO ::ApplicationUtilities::dependencyVersions = STATIC_DEPENCENCY_VERSIONS #define SET_DEPENDENCY_INFO ::ApplicationUtilities::dependencyVersions2 = STATIC_DEPENCENCY_VERSIONS
#endif #endif
/*! /*!

View File

@ -731,7 +731,7 @@ void ArgumentParserTests::testHelp()
parser.addMainArgument(&verboseArg); parser.addMainArgument(&verboseArg);
parser.addMainArgument(&filesArg); parser.addMainArgument(&filesArg);
parser.addMainArgument(&envArg); parser.addMainArgument(&envArg);
dependencyVersions = { "somelib", "some other lib" }; dependencyVersions2 = { "somelib", "some other lib" };
// parse args and assert output // parse args and assert output
const char *const argv[] = { "app", "-h" }; const char *const argv[] = { "app", "-h" };