From 2f2be617c1e2ccc0aaefbb2e56fb34046c645126 Mon Sep 17 00:00:00 2001 From: asterix Date: Wed, 11 Jan 2012 14:40:08 +0000 Subject: [PATCH] Add preprocessor FOR macro. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@5233 38d2e660-2303-0410-9eaa-f027e97ec537 --- bertos/cfg/for.h | 172 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 172 insertions(+) create mode 100644 bertos/cfg/for.h diff --git a/bertos/cfg/for.h b/bertos/cfg/for.h new file mode 100644 index 00000000..b3833ca2 --- /dev/null +++ b/bertos/cfg/for.h @@ -0,0 +1,172 @@ +/** + * \file + * + * + * \brief Preprocessor FOR macro. + * + * \author Francesco Sacchi + */ + +#ifndef CFG_FOR_H +#define CFG_FOR_H + +#define IDENTITY(x) x + +#define FOR(body, ...) \ + PP_CAT(FOR_, COUNT_PARMS(__VA_ARGS__)) (body, __VA_ARGS__) + +#define FOR_1(body, x) IDENTITY(body x) + +#define FOR_2(body, x, ...) \ + IDENTITY(body x) \ + FOR_1(body, __VA_ARGS__) + +#define FOR_3(body, x, ...) \ + IDENTITY(body x) \ + FOR_2(body, __VA_ARGS__) + +#define FOR_4(body, x, ...) \ + IDENTITY(body x) \ + FOR_3(body, __VA_ARGS__) + +#define FOR_5(body, x, ...) \ + IDENTITY(body x) \ + FOR_4(body, __VA_ARGS__) + +#define FOR_6(body, x, ...) \ + IDENTITY(body x) \ + FOR_5(body, __VA_ARGS__) + +#define FOR_7(body, x, ...) \ + IDENTITY(body x) \ + FOR_6(body, __VA_ARGS__) + +#define FOR_8(body, x, ...) \ + IDENTITY(body x) \ + FOR_7(body, __VA_ARGS__) + +#define FOR_9(body, x, ...) \ + IDENTITY(body x) \ + FOR_8(body, __VA_ARGS__) + +#define FOR_10(body, x, ...) \ + IDENTITY(body x) \ + FOR_9(body, __VA_ARGS__) + +#define FOR_11(body, x, ...) \ + IDENTITY(body x) \ + FOR_10(body, __VA_ARGS__) + +#define FOR_12(body, x, ...) \ + IDENTITY(body x) \ + FOR_11(body, __VA_ARGS__) + +#define FOR_13(body, x, ...) \ + IDENTITY(body x) \ + FOR_12(body, __VA_ARGS__) + +#define FOR_14(body, x, ...) \ + IDENTITY(body x) \ + FOR_13(body, __VA_ARGS__) + +#define FOR_15(body, x, ...) \ + IDENTITY(body x) \ + FOR_14(body, __VA_ARGS__) + +#define FOR_16(body, x, ...) \ + IDENTITY(body x) \ + FOR_15(body, __VA_ARGS__) + +#define FOR_17(body, x, ...) \ + IDENTITY(body x) \ + FOR_16(body, __VA_ARGS__) + +#define FOR_18(body, x, ...) \ + IDENTITY(body x) \ + FOR_17(body, __VA_ARGS__) + +#define FOR_19(body, x, ...) \ + IDENTITY(body x) \ + FOR_18(body, __VA_ARGS__) + +#define FOR_20(body, x, ...) \ + IDENTITY(body x) \ + FOR_19(body, __VA_ARGS__) + +#define FOR_21(body, x, ...) \ + IDENTITY(body x) \ + FOR_20(body, __VA_ARGS__) + +#define FOR_22(body, x, ...) \ + IDENTITY(body x) \ + FOR_21(body, __VA_ARGS__) + +#define FOR_23(body, x, ...) \ + IDENTITY(body x) \ + FOR_22(body, __VA_ARGS__) + +#define FOR_24(body, x, ...) \ + IDENTITY(body x) \ + FOR_23(body, __VA_ARGS__) + +#define FOR_25(body, x, ...) \ + IDENTITY(body x) \ + FOR_24(body, __VA_ARGS__) + +#define FOR_26(body, x, ...) \ + IDENTITY(body x) \ + FOR_25(body, __VA_ARGS__) + +#define FOR_27(body, x, ...) \ + IDENTITY(body x) \ + FOR_26(body, __VA_ARGS__) + +#define FOR_28(body, x, ...) \ + IDENTITY(body x) \ + FOR_27(body, __VA_ARGS__) + +#define FOR_29(body, x, ...) \ + IDENTITY(body x) \ + FOR_28(body, __VA_ARGS__) + +#define FOR_30(body, x, ...) \ + IDENTITY(body x) \ + FOR_29(body, __VA_ARGS__) + +#define FOR_31(body, x, ...) \ + IDENTITY(body x) \ + FOR_30(body, __VA_ARGS__) + +#define FOR_32(body, x, ...) \ + IDENTITY(body x) \ + FOR_31(body, __VA_ARGS__) + +#endif /* CFG_FOR_H */ -- 2.25.1