From e95d13adb1d5d948f5a538051b2b9b6d2a906e50 Mon Sep 17 00:00:00 2001 From: Patrick Pelissier Date: Sat, 4 Aug 2018 08:34:35 +0200 Subject: [PATCH] Add support for multiple M_LET on the same line without warning about shadow variables. --- example/ex-mph.c | 4 +--- m-core.h | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/example/ex-mph.c b/example/ex-mph.c index 3c92133c..89fa18fd 100644 --- a/example/ex-mph.c +++ b/example/ex-mph.c @@ -234,9 +234,7 @@ test(array_seed_t seed, array_value_t value, dict_mph_t dict) int main(int argc, const char *argv[]) { - M_LET(arr, array_string_t) - M_LET(dict, dict_mph_t) - M_LET(seed, array_seed_t) + M_LET(arr, array_string_t) M_LET(dict, dict_mph_t) M_LET(seed, array_seed_t) M_LET(value, array_value_t) { const char *filename = (argc > 1) ? argv[1] :"/usr/share/dict/words"; dict_read_from_file(dict, arr, filename); diff --git a/m-core.h b/m-core.h index c8f8400d..648fb2d3 100644 --- a/m-core.h +++ b/m-core.h @@ -1959,8 +1959,8 @@ m_core_hash (const void *str, size_t length) Last argument can be the oplist or the type itself if a global oplist has been recorded for this type. */ -#define M_LET(...) \ - M_ID(M_LETI1 M_INVERT( __VA_ARGS__, M_C(local_cont_, __LINE__) )) +#define M_LET(a, ...) \ + M_ID(M_LETI1 M_INVERT(a, __VA_ARGS__, M_C3(local_cont_, a, __LINE__) )) #define M_LETI1(cont, oplist, ...) \ M_LETI2(cont, M_GLOBAL_OPLIST(oplist), __VA_ARGS__)