Skip to content

Commit

Permalink
api-version: A better error message
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
algernon committed Dec 28, 2017
1 parent 5a1b453 commit 78cc806
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Kaleidoscope.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 78cc806

Please sign in to comment.