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

Introduce KALEIDOSCOPE_API_VERSION #270

Merged
merged 2 commits into from Jan 29, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/Kaleidoscope.h
Expand Up @@ -33,6 +33,36 @@ extern HARDWARE_IMPLEMENTATION KeyboardHardware;
#define VERSION "locally-built"
#endif

/** Kaleidoscope API (major) version.
*
* The API is guaranteed to be backwards compatible for the entire duration of a
* major version. However, breaking changes may come, and result in a major
* version bump. To help migration, the `KALEIDOSCOPE_API_VERSION` macro can be
* used to check the major version provided by the Kaleidoscope we are compiling
* against. This can be used to error out with a helpful message, or change how
* the API is used - it is entirely up to the plugin or sketch author. The point
* of this macro is to let them easily check the version.
*/
#define KALEIDOSCOPE_API_VERSION 1

/** Required Kaleidoscope major version.
*
* For the sake of convenience, defining `KALEIDOSCOPE_REQUIRED_API_VERSION`
* before including `Kaleidoscope.h` itself will result in comparing its value
* to `KALEIDOSCOPE_API_VERSION`. If they differ, a helpful error message is
* printed.
*
* Done so that a new API version would result in a helpful error message,
* instead of cryptic compile errors.
*/
#if defined(KALEIDOSCOPE_REQUIRED_API_VERSION) && (KALEIDOSCOPE_REQUIRED_API_VERSION != KALEIDOSCOPE_API_VERSION)
#define xstr(a) str(a)
#define str(a) #a
static_assert(KALEIDOSCOPE_REQUIRED_API_VERSION == KALEIDOSCOPE_API_VERSION,
"Kaleidoscope API version mismatch! We have version " xstr(KALEIDOSCOPE_API_VERSION)
" available, but version " xstr(KALEIDOSCOPE_REQUIRED_API_VERSION) " is required.");
#endif

const uint8_t KEYMAP_SIZE
__attribute__((deprecated("Kaleidoscope.setup() does not require KEYMAP_SIZE anymore."))) = 0;

Expand Down