Skip to content

Instantly share code, notes, and snippets.

@mildsunrise
Last active December 18, 2015 11:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mildsunrise/5775816 to your computer and use it in GitHub Desktop.
Save mildsunrise/5775816 to your computer and use it in GitHub Desktop.
You see, comparing versions is a form of art.
// My artistic composition is able to compare
// two versions in a single expression! YAY!
#define FOO_AVAILABLE(major, \
minor, \
patch) \
\
( FOO_MAJOR_VERSION >major || \
( FOO_MAJOR_VERSION==major && \
\
( FOO_MINOR_VERSION >minor || \
( FOO_MINOR_VERSION==minor && \
\
( FOO_PATCH_VERSION >patch || \
( FOO_PATCH_VERSION==patch && \
\
+ - - - - - - - - - - 8)) )) ))
#if FOO_AVAILABLE(3,7,2)
Bar superAwesomeMethod() {
return onlyAvailableInLatestFoo();
}
#else
// The user needs to upgrade
// his foo. Definitively.
#error "You need Foo 3.7.2 or later."
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment