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

Request: Add version number in header files #458

Closed
marcalff opened this issue Aug 3, 2024 · 0 comments · Fixed by #459
Closed

Request: Add version number in header files #458

marcalff opened this issue Aug 3, 2024 · 0 comments · Fixed by #459

Comments

@marcalff
Copy link
Contributor

marcalff commented Aug 3, 2024

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.

marcalff added a commit to marcalff/rapidyaml that referenced this issue Aug 3, 2024
biojppm pushed a commit to marcalff/rapidyaml that referenced this issue Aug 13, 2024
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

Successfully merging a pull request may close this issue.

1 participant