Skip to content

Request: Add version number in header files #458

@marcalff

Description

@marcalff

Please add version numbers in header files, that can be used at compile time.

For example:

#define RYML_VERSION "0.7.0"
#define RYML_VERSION_MAJOR 0
#define RYML_VERSION_MINOR 7
#define RYML_VERSION_PATCH 0

This helps when code using ryml needs to be different for v0.6.0 and v0.7.0, due to api breaking changes.

To illustrate, right now my application code looks like:

  ryml::ParserOptions opts;
  opts.locations(true);

#if OTEL_HAVE_RYML == 6
  ryml::Parser parser(opts);
#endif

#if OTEL_HAVE_RYML == 7
  ryml::Parser::handler_type event_handler;
  ryml::Parser parser(&event_handler, opts);
#endif

  ryml::Tree tree;
  ryml::csubstr filename;
  ryml::csubstr csubstr_content;
  std::unique_ptr<Document> doc;

  filename        = ryml::to_csubstr(source);
  csubstr_content = ryml::to_csubstr(content);

  try
  {
#if OTEL_HAVE_RYML == 6
    tree = parser.parse_in_arena(filename, csubstr_content);
#endif

#if OTEL_HAVE_RYML == 7
    tree = parse_in_arena(&parser, filename, csubstr_content);
#endif

    tree.resolve();
  }
  catch (...)

where OTEL_HAVE_RYML is evaluated by CMake, based on what find_package() actually found.

It is desirable to rely on RYML_VERSION_MAJOR, RYML_VERSION_MINOR and RYML_VERSION_PATCH found in the ryml header files instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions