From 89a9ef8492ac755394bd65df24fce220b3d26b40 Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Mon, 13 Sep 2021 10:37:15 +0200 Subject: Made a change to macro overloading so that intellisense for VS Code works (again). --- include/stc/ccommon.h | 6 ++++-- include/stc/cmap.h | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/stc/ccommon.h b/include/stc/ccommon.h index b2501416..e901f499 100644 --- a/include/stc/ccommon.h +++ b/include/stc/ccommon.h @@ -53,9 +53,11 @@ /* Macro overloading feature support based on: https://rextester.com/ONP80107 */ #define c_MACRO_OVERLOAD(name, ...) \ - c_SELECT(name, c_NUM_ARGS(__VA_ARGS__))(__VA_ARGS__) -#define c_SELECT(name, num) c_CONCAT(name ## _, num) + c_PASTE3(name, _, c_NUM_ARGS(__VA_ARGS__))(__VA_ARGS__) #define c_CONCAT(a, b) a ## b +#define c_CONCAT3(a, b, c) a ## b ## c +#define c_PASTE(a, b) c_CONCAT(a, b) +#define c_PASTE3(a, b, c) c_CONCAT3(a, b, c) #define c_EXPAND(...) __VA_ARGS__ #define c_NUM_ARGS(...) _c_APPLY_ARG_N((__VA_ARGS__, _c_RSEQ_N)) diff --git a/include/stc/cmap.h b/include/stc/cmap.h index 68a5fd4b..476558c7 100644 --- a/include/stc/cmap.h +++ b/include/stc/cmap.h @@ -368,7 +368,7 @@ STC_INLINE size_t fastrange_uint64_t(uint64_t x, uint64_t n) \ CX##_bucket_(const CX* self, const CX##_rawkey_t* rkeyptr) { \ const uint64_t _hash = keyHashRaw(rkeyptr, sizeof *rkeyptr); \ uint_fast8_t _hx; size_t _cap = self->bucket_count; \ - chash_bucket_t b = {c_SELECT(fastrange,CMAP_SIZE_T)(_hash, _cap), (uint_fast8_t)(_hash | 0x80)}; \ + chash_bucket_t b = {c_PASTE(fastrange_,CMAP_SIZE_T)(_hash, _cap), (uint_fast8_t)(_hash | 0x80)}; \ const uint8_t* _hashx = self->_hashx; \ while ((_hx = _hashx[b.idx])) { \ if (_hx == b.hx) { \ @@ -444,7 +444,7 @@ STC_INLINE size_t fastrange_uint64_t(uint64_t x, uint64_t n) \ if (! _hashx[j]) \ break; \ CX##_rawkey_t _raw = keyToRaw(KEY_REF_##C(_slot+j)); \ - k = c_SELECT(fastrange,CMAP_SIZE_T)(keyHashRaw(&_raw, sizeof _raw), _cap); \ + k = c_PASTE(fastrange_,CMAP_SIZE_T)(keyHashRaw(&_raw, sizeof _raw), _cap); \ if ((j < i) ^ (k <= i) ^ (k > j)) /* is k outside (i, j]? */ \ memcpy((void *) &_slot[i], &_slot[j], sizeof *_slot), _hashx[i] = _hashx[j], i = j; \ } \ -- cgit v1.2.3