diff -r 413ecd6b9801 -r fa025ba493d8 src/macros.h --- a/src/macros.h Wed Nov 18 19:05:22 2015 +0200 +++ b/src/macros.h Thu Nov 19 00:43:18 2015 +0200 @@ -65,3 +65,27 @@ NAME = ENUM::NumValues) #define ConfigOption(...) + +// once-statement +struct OnceGuard +{ + bool triggered; + OnceGuard() : triggered (false) {} + + bool pass() + { + if (triggered) + { + return false; + } + else + { + triggered = true; + return true; + } + } +}; + +#define TEE_2(A,B) A ## B +#define TEE(A,B) TEE_2(A,B) +#define once static OnceGuard TEE(_once_, __LINE__); if (TEE(_once_, __LINE__).pass())