Last active
December 18, 2015 11:29
-
-
Save mildsunrise/5775816 to your computer and use it in GitHub Desktop.
You see, comparing versions is a form of art.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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)) )) )) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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