Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider adding version information to the main header file #411

Closed
alabuzhev opened this issue Nov 3, 2016 · 3 comments
Closed

Consider adding version information to the main header file #411

alabuzhev opened this issue Nov 3, 2016 · 3 comments

Comments

@alabuzhev
Copy link
Contributor

To allow client code rertieve library version instead of hard-coding it somewhere.

Motivation:

  • informational purposes / troubleshooting (e. g. about box or log file with detailed list of used libraries)
  • validation that code is being compiled with compatible version (e. g. if source is pulled from somewhere)

Can be in form of preprocessor definitions for integral version components (major, minor etc.) or preformatted string, e. g. "3.0.0". For example, SQLite defines these macros:

#define SQLITE_VERSION        "3.15.0"
#define SQLITE_VERSION_NUMBER 3015000
@foonathan
Copy link
Contributor

Good point.

@vitaut The version information is currently only available in CMake.
While it is easy to pass it to a C++ header, this requires an external CMake configuration step.
We could go the other way and parse the version from the header file, but I don't think the trouble is worth it compared to simply keeping two macros in sync.

@vitaut
Copy link
Contributor

vitaut commented Nov 6, 2016

I am thinking of defining a single FMT_VERSION macro in the form

#define FMT_VERSION MMmmpp

as suggested for GCC here, where MM is a major version, mm is a minor version, and pp is a patch number, for example,

#define FMT_VERSION 030001

is version 3.0.1.

I think it is better than having separate major, minor, and patch macros because it requires awkward comparison:

/* Test for GCC > 3.2.0 */
          #if __GNUC__ > 3 || \
              (__GNUC__ == 3 && (__GNUC_MINOR__ > 2 || \
                                 (__GNUC_MINOR__ == 2 && \
                                  __GNUC_PATCHLEVEL__ > 0))

Major, minor, and patch version can be easily extracted from FMT_VERSION.

As for CMake, I think it's better to extract version from the header file to avoid duplication.

vitaut added a commit that referenced this issue Nov 8, 2016
vitaut added a commit that referenced this issue Nov 8, 2016
@vitaut
Copy link
Contributor

vitaut commented Nov 8, 2016

Done in f5b1c16.

@vitaut vitaut closed this as completed Nov 8, 2016
foonathan pushed a commit that referenced this issue Jun 8, 2017
(cherry picked from commit f5b1c16)

# Conflicts:
#	CMakeLists.txt
vitaut added a commit that referenced this issue Jan 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants