From 3416442dda8c96c4c276002e44b2c5a71d0e9d75 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Tue, 2 Feb 2021 11:41:26 +1000 Subject: [PATCH] preprocessor: add COUNT_MAP --- preprocessor.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/preprocessor.py b/preprocessor.py index 646f701b..ec603c5c 100755 --- a/preprocessor.py +++ b/preprocessor.py @@ -168,6 +168,10 @@ if __name__ == '__main__': #define APPEND_COMMA(X) X, +#define ONE_PLUS(ARG) 1+ +/// Given the functional macro `FUNC`, that applies some macro to a list of +/// elements, find the number of elements in `FUNC`. +#define COUNT_MAP(FUNC) (FUNC(ONE_PLUS)+0) #define STRINGIZE_DETAIL(x) #x #define STRINGIZE(x) STRINGIZE_DETAIL(x)