api-version: A better error message

Use `static_assert` instead of `#error` to report an API mismatch, resulting in
a much more informative error message.

Thanks to @cdisselkoen for the request, and @noseglasses for the `static_assert`
idea!

Signed-off-by: Gergely Nagy <algernon@keyboard.io>
pull/270/head
Gergely Nagy 7 years ago
parent 5a1b453b36
commit 78cc8064c5

@ -56,7 +56,11 @@ extern HARDWARE_IMPLEMENTATION KeyboardHardware;
* instead of cryptic compile errors.
*/
#if defined(KALEIDOSCOPE_REQUIRED_API_VERSION) && (KALEIDOSCOPE_REQUIRED_API_VERSION != KALEIDOSCOPE_API_VERSION)
#error Kaleidoscope API version mismatch! The plugin or sketch requires a different API version than what is available.
#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

Loading…
Cancel
Save