Skip to content
New issue

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

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

Already on GitHub? # to your account

Version preprocessor macros are not really usable #374

Closed
tmadlener opened this issue Feb 10, 2023 · 0 comments · Fixed by #375
Closed

Version preprocessor macros are not really usable #374

tmadlener opened this issue Feb 10, 2023 · 0 comments · Fixed by #375
Labels

Comments

@tmadlener
Copy link
Collaborator

The preprocessor macros and constants that are defined in podioVersion.h (configured from podioVersion.h.in) cannot be used in preprocesser #if directives. The problem is that preprocessor macros don't support any casting, as done e.g. here:

podio/podioVersion.in.h

Lines 15 to 16 in 811aca9

#define PODIO_VERSION(major, minor, patch) \
(((unsigned long)(major) << 32) | ((unsigned long)(minor) << 16) | ((unsigned long)(patch)))

This makes the trivial program

#include "podio/podioVersion.h"

int main() {
#if PODIO_BUILD_VERSION > PODIO_VERSION(0, 16, 2)
  return 0;
#else
  return 1;
#endif
}

fail to build with

../include/podio/podioVersion.h:16:15: error: missing binary operator before token "long"
   16 |   (((unsigned long)(major) << 32) | ((unsigned long)(minor) << 16) | ((unsigned long)(patch)))
      |               ^~~~
../include/podio/podioVersion.h:31:29: note: in expansion of macro ‘PODIO_VERSION’
   31 | #define PODIO_BUILD_VERSION PODIO_VERSION(podio_VERSION_MAJOR, podio_VERSION_MINOR, podio_VERSION_PATCH)
      |                             ^~~~~~~~~~~~~
../tests/version_test.cpp:4:5: note: in expansion of macro ‘PODIO_BUILD_VERSION’
    4 | #if PODIO_BUILD_VERSION > PODIO_VERSION(0, 16, 2)
      |     ^~~~~~~~~~~~~~~~~~~
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant