From cea8ac9a2242512e9d0dc27a71dd458340c1d8db Mon Sep 17 00:00:00 2001 From: Peter Boyle Date: Fri, 21 Aug 2015 10:14:53 +0100 Subject: [PATCH] Credits to orig source where I found the macro tricks. --- lib/serialisation/MacroMagic.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lib/serialisation/MacroMagic.h b/lib/serialisation/MacroMagic.h index c5b32528..f1ef051c 100644 --- a/lib/serialisation/MacroMagic.h +++ b/lib/serialisation/MacroMagic.h @@ -1,6 +1,25 @@ #ifndef GRID_MACRO_MAGIC_H #define GRID_MACRO_MAGIC_H +/////////////////////////////////////////// +// Strong credit to : +// +// http://jhnet.co.uk/articles/cpp_magic +// +// +// "The C Pre-Processor (CPP) is the somewhat basic macro system used by the C +// programming language to implement features such as #include and #define +// which allow very simple text-substitutions to be carried out at compile time. +// In this article we abuse the humble #define to implement if-statements and iteration. +// +// Before we begin, a disclaimer: these tricks, while perfectly valid C, should not be +// considered good development practice and should almost certainly not be used for "real work". +// That said it can totally be used for fun home-automation projects... +// +// https://github.com/18sg/uSHET/blob/master/lib/cpp_magic.h +// +/////////////////////////////////////////// + #define strong_inline __attribute__((always_inline)) inline #ifndef MAX