# Trick to ensure used-defined keys (not in Ranges) don't collide?

**URL:** https://community.keyboard.io/t/trick-to-ensure-used-defined-keys-not-in-ranges-dont-collide/1907
**Category:** Programming
**Created:** [August 12, 2018, 9:36am UTC](https://community.keyboard.io/t/trick-to-ensure-used-defined-keys-not-in-ranges-dont-collide/1907 "2018-08-12T09:36:35Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![jamadagni](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.keyboard.io/jamadagni/32/2030_2.png) [@jamadagni](https://community.keyboard.io/u/jamadagni)
#### Post date: [August 12, 2018, 9:36am UTC](https://community.keyboard.io/t/trick-to-ensure-used-defined-keys-not-in-ranges-dont-collide/1907/1 "2018-08-12T09:36:35Z")

</div>

I was wondering how **MacrosOnTheFly** defines the _MacroRec_ and _MacroPlay_ keys but they aren’t defined in **Ranges** and I find [these lines](https://github.com/cdisselkoen/Kaleidoscope-MacrosOnTheFly/blob/master/src/Kaleidoscope/MacrosOnTheFly.h#L25):

```auto
#define MACROREC kaleidoscope::ranges::KALEIDOSCOPE_SAFE_START
#define MACROPLAY kaleidoscope::ranges::KALEIDOSCOPE_SAFE_START + 1
#define Key_MacroRec (Key) {.raw = MACROREC}
#define Key_MacroPlay (Key) {.raw = MACROPLAY}

```

I’m not so sure how “safe” `SAFE_START` is because if more than one third-party plugin that wants to create synthetic keys not having official key codes allotted in **Ranges** starts using it, it isn’t “safe” any longer, because there is no guarantee that another third-party won’t use the same values!

I was thinking of maybe a registrar that would allot synthetic keycodes upon request, and that would avoid such plugin conflict, but since there isn’t any CTFE (compile time function evaluation, which I came across in D) in C++, I’m not sure how to get values on to the keymap which is marked PROGMEM at compile time!

I have to investigate whether the implementation-provided [` __COUNTER__ ` pre-processor macro](https://stackoverflow.com/questions/652815/has-anyone-ever-had-a-use-for-the-counter-pre-processor-macro) can help here.

In the meanwhile, any thoughts?

---

<div class="post-metadata">

### Author: ![algernon](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.keyboard.io/algernon/32/4404_2.png) [@algernon](https://community.keyboard.io/u/algernon)
#### Post date: [August 12, 2018, 5:01pm UTC](https://community.keyboard.io/t/trick-to-ensure-used-defined-keys-not-in-ranges-dont-collide/1907/2 "2018-08-12T17:01:13Z")

</div>

The easiest approach would be to submit a PR against `Kaleidoscope-Ranges` 😉
