Created
October 22, 2012 00:04
-
-
Save darkfall/3929023 to your computer and use it in GitHub Desktop.
ukn static run code/call func
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define UKN_STATIC_RUN_CODE_I(name, code) \ | |
namespace { \ | |
static struct name { \ | |
name() { \ | |
code; \ | |
} \ | |
} UKN_JOIN(g_, name); \ | |
} | |
#define UKN_STATIC_RUN_CODE(code) \ | |
UKN_STATIC_RUN_CODE_I(UKN_UNIQUE_NAME(UKN_static_), code) | |
#define UKN_STATIC_CALL_FUNC_I(name, FN) \ | |
namespace { \ | |
static struct name { \ | |
name() { \ | |
static int counter = 0; \ | |
if(counter++ > 0) return; \ | |
FN(); \ | |
} \ | |
} g_##name; \ | |
} | |
#define UKN_STATIC_CALL_FUNC(FN) \ | |
UKN_STATIC_CALL_FUNC_I(UKN_static_init_##FN, FN) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment