From 7860c38bfe99b466659b4351d514ab43aa93de31 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Mon, 2 Jul 2018 10:51:01 +0200 Subject: [PATCH] plugins: improve documentation of REGISTER_PLUGIN macro --- include/villas/plugin.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/include/villas/plugin.h b/include/villas/plugin.h index d373ab338..a015c2e49 100644 --- a/include/villas/plugin.h +++ b/include/villas/plugin.h @@ -35,7 +35,17 @@ extern "C"{ #endif -/** @todo This is ugly as hell and broken on OS X / Clang anyway. */ +/** (De-)Register a plugin by adding it to the global plugin list. + * + * We make use of GCC's / Clang's constructor/destructor function + * attributes to let the following code be executed by the loader. + * This works only when we compile libvillas as a shared library! + * + * The __attribute__((constructor)) / __attribute__((destructor)) + * is currently only supported by GCC and Clang + * + * See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#Common-Function-Attributes + */ #define REGISTER_PLUGIN(p) \ __attribute__((constructor(110))) static void UNIQUE(__ctor)() {\ if (plugins.state == STATE_DESTROYED) \ @@ -102,4 +112,4 @@ struct plugin * plugin_lookup(enum plugin_type type, const char *name); #ifdef __cplusplus } -#endif \ No newline at end of file +#endif