Skip to content

Comparable Colvars version #809

@HanatoK

Description

@HanatoK

Currently version of Colvars is set by the colvars_version.h:

#ifndef COLVARS_VERSION
#define COLVARS_VERSION "2025-05-12"
#endif

It is a bit difficult to compare different Colvars version strings and compile external C++ code conditionally based on different versions of Colvars. I am a bit worried that by introducing #788, any 3rd C++ code (for example, those code in https://www.ks.uiuc.edu/Training/Tutorials/#namd:~:text=Customizing%20CVs%20in%20NAMD%3A) relying on the Colvars internal APIs won't work, so it would be better to provide a way to conditionally compile C++ code based on the Colvars version.

I propose the following solution:

#ifndef COLVARS_VERSION

#include <cstdint>

#define COLVARS_VERSION_YEAR 2025
#define COLVARS_VERSION_MONTH 05
#define COLVARS_VERSION_DATE  12

#define COLVARS_VERSION_STR_HELPER(x) #x
#define COLVARS_VERSION_STR(x) COLVARS_VERSION_STR_HELPER(x)

#define COLVARS_VERSION \
        COLVARS_VERSION_STR(COLVARS_VERSION_YEAR) "-"\
        COLVARS_VERSION_STR(COLVARS_VERSION_MONTH) "-"\
        COLVARS_VERSION_STR(COLVARS_VERSION_DATE)

#define COLVARS_VERSION_UINT64(a,b,c) \
        ((UINT64_C(a) << 16) + (UINT64_C(b) << 8) + UINT64_C(c))
#define COLVARS_VERSION_UINT64_CURRENT \
        COLVARS_VERSION_UINT64(COLVARS_VERSION_YEAR, \
                               COLVARS_VERSION_MONTH, \
                               COLVARS_VERSION_DATE)

#endif

But it looks like that will break other shell scripts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions