summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2015-09-14 20:21:32 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2015-09-14 20:21:32 +0100
commit4e7d73fa948532e3fabe06ffdcf73b60ec078df5 (patch)
tree9066f98f4316c96cf05d3892c5d2bc2711d4cef7
parentFix typeid use in PluginOf (diff)
downloadlibadhocutil-4e7d73fa948532e3fabe06ffdcf73b60ec078df5.tar.bz2
libadhocutil-4e7d73fa948532e3fabe06ffdcf73b60ec078df5.tar.xz
libadhocutil-4e7d73fa948532e3fabe06ffdcf73b60ec078df5.zip
Create a unique namespace for plugin registry functions
-rw-r--r--libadhocutil/plugins.h3
-rw-r--r--libadhocutil/unique.h9
2 files changed, 11 insertions, 1 deletions
diff --git a/libadhocutil/plugins.h b/libadhocutil/plugins.h
index 69dd05c..5efd5b5 100644
--- a/libadhocutil/plugins.h
+++ b/libadhocutil/plugins.h
@@ -11,6 +11,7 @@
#include <set>
#include <algorithm>
#include "visibility.h"
+#include "unique.h"
namespace std {
DLL_PUBLIC
@@ -146,7 +147,7 @@ namespace AdHoc {
}
#define NAMEDPLUGIN(Name, Implementation, Base) \
- namespace { \
+ namespace MAKE_UNIQUE(__plugin__) { \
static void InstallPlugin() __attribute__((constructor(102))); \
void InstallPlugin() { \
::AdHoc::PluginManager::getDefault()->add<Base>(new Implementation(), Name, __FILE__, __LINE__); \
diff --git a/libadhocutil/unique.h b/libadhocutil/unique.h
new file mode 100644
index 0000000..5c77907
--- /dev/null
+++ b/libadhocutil/unique.h
@@ -0,0 +1,9 @@
+#ifndef ADHOCUTIL_UNIQUE_H
+#define ADHOCUTIL_UNIQUE_H
+
+#define CONCATENATE_DETAIL(x, y) x##y
+#define CONCATENATE(x, y) CONCATENATE_DETAIL(x, y)
+#define MAKE_UNIQUE(x) CONCATENATE(x, __COUNTER__)
+
+#endif
+